How can I monitor several projects simultaneously in TypeScript using tsc?

I have a scenario where I have two different tsconfig.json files - one in the root directory and another in the test folder:

.
├── dist
│   └── file...
├── dist-test
│   └── file...
├── src
│   └── file...
├── test
│   ├── file...
│   └── tsconfig.json
└── tsconfig.json

In this setup, files from the src folder compile into the dist directory, while files from the test folder compile into the dist-test directory.

When working from the root directory, I can use either tsc -w or tsc -w --project test to watch for changes in the files. Is there a way to run both commands simultaneously within the same terminal?

I attempted to execute

(tsc -w) && (tsc -w --project test)
, but it did not work as expected. Only the first command is executed, and it only compiles the dist directory.

UPD: This question differs from How can I run multiple npm scripts in parallel? because I am specifically dealing with the tsc utility, which, I believe, should be able to handle compiling two projects at once without requiring parallel processing with different programs.

Answer №1

It seems like you're leaning more towards a "bash" question rather than TypeScript:

Running 2 instances of tsc is the correct approach, as each tsconfig.json file requires its own instance.

In your scenario, the first tsc will be launched in watch mode and will only proceed to the second tsc once it's finished.

You could give this a try for improved performance:

(tsc -w &) && (tsc -w --project test)

This command starts the first tsc process in the background (requiring manual termination if needed) and then launches the second one concurrently.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Explaining the data link between a service and component: understanding Subject and BehaviorSubject

Can someone explain the concepts of Subject and BehaviorSubject in Angular to me? I'm new to Angular and struggling to understand. I've tried searching online, but I still can't grasp how they work. The same goes for Observable and Observer ...

AngularJS is encountering issues with dependency injections when using WebStorm and TypeScript

A TypeScript AngularJS component: class MyComponentCtrl { static $inject = ['MyService']; constructor(private MyService) { MyService.testfn(55); // No error in typescript } } class MyComponent implements ng.IComponentOptions { ...

What advantages does using a callback offer compared to await?

For a project focused on user-related tasks, I crafted the following code snippet within my service file. let result: User | null = await userModel.registerUser(); return result; After receiving feedback from my team advising to "Use callback rather than ...

Inheritance from WebElement in WebdriverIO: A Beginner's Guide

I am seeking a solution to extend the functionality of the WebElement object returned by webdriverio, without resorting to monkey-patching and with TypeScript type support for autocompletion. Is it possible to achieve this in any way? class CustomCheckb ...

How to Access Static Method from Non-Static Method in TypeScript

Within my hierarchy, there is some static content present in all levels (for example, the _image). It would be ideal to access the corresponding _image without repeating code: Here's what I envision: class Actor { static _image; // Needs to be s ...

"Exploring the use of TypeScript in React higher order components

Check out this article for a detailed explanation of HOC: https://medium.com/@jrwebdev/react-higher-order-component-patterns-in-typescript-42278f7590fb Here is the code I have written using HOC: import * as React from 'react'; import Dropzone f ...

The table component in Primeng is encountering issues when being used with ngFor

I'm attempting to iterate through an array where each object represents a table in HTML, and it should be displayed like this: <p-table [value]="section" *ngFor="let section of sections"> <ng-template pTemplate="header"> <t ...

Handling exception type in child_process exec method - NodeJS with Typescript integration

Check out this sample code: const execPromise = util.promisify(exec); try { const { stdout } = await execPromise(cliCommand); } catch (error) { if (error instanceof S3ServiceException) { // error message is not handled correctly console ...

The parameter type (key: string, id: string, pagination: number) in the argument does not match the expected type of Boolean for the parameter

I'm facing an issue while trying to implement the following documentation: https://swr.vercel.app/ using my own setup: import React, { useEffect } from 'react' import PatientsTable from 'components/patients/PatientsTable' import ...

Implementing horizontal scrolling using the mouse wheel in typescript

Attempting to activate horizontal scrolling via mouse wheel using TypeScript has presented a challenge. It seems that updating the value of deltaX is not permitted within TypeScript. Any suggestions or solutions for this issue? Here is a snippet of my co ...

Using React and TypeScript, open the initial tab from a mapped array with an accordion component

{accordion.map(accordionItem => ( <AccordionItem key={accordionItem.title} text={accordionItem.text} title={accordionItem.title} ></AccordionItem> ...

Is it possible to nest forkJoins within another forkJoin call?

I have implemented a route resolver in this manner, where I want to make two additional HTTP requests based on the initial response from forkjoin. I attempted to nest another forkjoin inside the first one, but I am open to suggestions on better approache ...

Is it possible for a property to be null or undefined on class instances?

Consider this TypeScript interface: export interface Person { phone?: number; name?: string; } Does having the question mark next to properties in the interface mean that the name property in instances of classes implementing the interface ca ...

What are the steps for creating a custom repository with TypeORM (MongoDB) in NestJS?

One query that arises is regarding the @EntityRepository decorator becoming deprecated in typeorm@^0.3.6. What is now the recommended or TypeScript-friendly approach to creating a custom repository for an entity in NestJS? Previously, a custom repository w ...

Angular: Trigger service call upon onBlur event of input changes

In Angular, I am looking to detect any changes in the text input during the onBlur event and then take specific actions accordingly: Criteria for processing during the onBlur event: Only proceed if there has been a change in the text input. If the input ...

Tabs in React display tab content vertically below each other when switching between tabs

I am currently working on creating Tabs using react-tabs. The tab contents are being displayed one after another (on different tabs) as shown below Here is the code snippet: <Tabs className="tabs"> <TabList className="tab-heade ...

Strategies for monitoring for state changes in Angular 4/6

I am currently working on designing a webpage for account information. This web page will have 4 pre-filled fields - given name, family name, username, and email. There will also be a common save button at the bottom of the form. Users should be able to ch ...

What is the best way to click on a particular button without activating every button on the page?

Struggling to create buttons labeled Add and Remove, as all the other buttons get triggered when I click on one. Here's the code snippet in question: function MyFruits() { const fruitsArray = [ 'banana', 'banana', & ...

Save a collection of interfaces/types in TypeScript

Exploring a new approach has presented me with a minor challenge: This is what I have=> export interface SynchGroupSubject { type: SynchGroupEvent; target: any; } export enum SynchGroupEvent { ADD_MAP, REMOVE_MAP } Within a service, the fol ...

Beginner in Typescript - Exploring ways to verify an interface using an index

When working with a list of operations in a database, each operation may have a unique set of variables that need to be passed. To make adding new operations easier, I decided to store the interfaces within a list structure like this: const operation = { ...