Is it possible to predict the completion time of the initial build when using the "--watch" option for TypeScript compilation?

Simultaneously building Tokens and ModulesCollection can occur in parallel while the Lexer will build once Tokens and ModulesCollection are built for the first time. The following code snippet contains an error due to the use of & in the line

npm run "Incremental building" &
:

cd UAA_Generators/JapaneseSyntax/ByNodeJS/DataStructures/Tokens || exit
npm run "Incremental building" &

cd ../ModulesCollection || exit
npm run "Incremental building" &

cd ../../Actuators/Lexer || exit
npm run "Incremental building"

The script for "Incremental building" is the same for each subproject:

rimraf Distributable & tsc --watch

The issue arises because of the --watch option, causing the task to never end (unless manually terminated). Is there a way to determine when the initial building of Tokens and ModulesCollection is complete?

Please keep in mind that I require rebuilding upon changes, so simply disabling the --watch option is not a viable solution.

Answer №1

If you're looking for an alternative solution, consider creating a customized build script tailored to this specific scenario. Utilize vanilla Node.js, Gulp, or Grunt; with my personal recommendation being Gulp.

Essentially, when an independent command is running concurrently with a dependent shell command using &, the dependent command will not execute until the independent one has completed. To enable parallelism, these commands should operate in separate non-blocking terminals as individual processes.

Typescript offers detailed guidance on setting up watch mode and incorporating Gulp with Typescript.

The functionality of --watch relies on utilizing fs.watch and fs.watchFile internally.

You could potentially employ Gulp's watch() and parallel() functions to achieve the desired build behavior.


Alternatively, exploring methods of achieving parallelism through pure Shell scripting with endless commands may lead to complexity involving invoking child processes and more.

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

Can a class property that necessitates type arguments be assigned in a lazy manner?

I find myself in a bit of a dilemma. The class I have is within my control for modifications, but it needs to be dynamically instantiated by an external code that I have no authority over. Unfortunately, this code cannot pass generic type arguments to the ...

Type 'Partial' cannot be assigned a value when combining interfaces with generic types

Consider the following scenario: class Table<ValuesType extends DefaultTableValues = DefaultTableValues>{ public values: ValuesType; constructor(initialValues:ValuesType) { this.values=initialValues; } public set(newValues:Pa ...

Firebase functions are having trouble identifying the routes in the express app that are located outside of the

Recently, I faced an issue while deploying a TypeScript project to firebase-functions where all the code was stored in index.ts. Initially, everything worked fine but when I decided to refactor my code, I discovered that firebase was not able to recognize ...

Encountering a problem while attempting to initiate a React app with npm start, an error

I am a beginner in web development with React and I recently followed these steps - npm install -g create-react-app create-react-app my-app cd my-app npm start However, I encountered the following error message: E:\Study\React-course\React- ...

Leveraging Angular's ActivatedRoute without injecting it into a component

I'm attempting to create a helper function using ActivatedRoute to retrieve URL parameters for me. The traditional method of injecting ActivatedRoute into the component has been successful, as shown below: constructor( private route: ActivatedRou ...

Comparison between a Typescript optional field and a field that has the potential to be undefined

Can you clarify the contrast between an optional field and a T | undefined field? export interface Example { property1: string | undefined property2?: string } ...

Unable to initiate a new React project

I am facing an issue while trying to set up a React project using npm. The global version of npm-create-react is no longer supported and even after following the recommended steps, I am unable to proceed. When I input the command npm init react-app my-app ...

An error was encountered in compiler.js at line 1021, stating that an unexpected value 'UserService' was imported by the module 'UserModule'. It is recommended to add a @NgModule annotation to resolve this issue

As a PHP programmer new to Angular, I am facing an issue while trying to retrieve user properties from a Laravel API. When attempting this, I encountered the following error: compiler.js:1021 Uncaught Error: Unexpected value 'UserService' importe ...

Issue encountered during Heroku deployment: Failed to build React app. When attempting to push changes to Heroku, an unexpected end of input error was received instead of the expected result. This error occurred on an unidentified file at

Encountering a parsing error while attempting to deploy a React app on Heroku using git push heroku master. The app built successfully yesterday, but since then some media queries were added by another contributor to various .scss files. The primary error ...

What is the process for invoking instance methods dynamically in TypeScript?

There is an object in my possession and the goal is to dynamically invoke a method on it. It would be ideal to have typechecking, although that may prove to be unattainable. Unfortunately, the current situation is that I cannot even get it to compile: ...

What is the best way to mock an internal function within my route using sinon?

Currently, I have my own internal function defined in the greatRoute.ts file: //in greatRoute.ts async function _secretString(param: string): Promise<string> { ... } router .route('/foo/bar/:secret') .get( async (...) => { ...

Exploring the latest whatwg-fetch update with TypeScript version 2.5.3

Within my TypeScript project, I am currently utilizing "whatwg-fetch": "2.0.3" as the latest version of this polyfill. Additionally, for types, I am using version "@types/whatwg-fetch": "0.0.33", and everything functions smoothly when working with TypeScri ...

Type generic in TypeScript

I'm having trouble understanding the code snippet below from redux-form export type DataSelector<FormData = {}, State = {}> = (formName: string, getFormState?: GetFormState) => (state: State) => FormData; export const getFormValues: Data ...

Installing 'q' using 'npm install q --save' will only save it in

It's baffling how everytime I run npm install q --save, the module q gets saved in devDependencies and not in dependencies. This strange behavior is consistent across all modules, not just q. Regardless of the install flags I try to use, modules alway ...

Setting up a Yeoman generator on a global scale via npm and utilizing a Github fork for development

My collection of installed global Yeoman generators is quite extensive (such as generator-angular and generator-meanjs). I am interested in forking one or two of them to contribute back to the community. However, I am unsure of how to proceed in terms of ...

How is it possible that TypeScript does not provide a warning when a function is called with a different number of arguments than what is expected?

I am working on a vanilla JavaScript project in VS Code and have set up jsconfig.json. Here is an example of the code I am using: /** * @param {(arg: string) => void} nestedFunction */ function myFunction(nestedFunction) { // Some logic here } myFu ...

When incorporating @pokusew/pcsclite into an Angular2/Electron project, a TypeError is triggered

In my Electron project with Angular CLI, I am attempting to implement NFC functionality by incorporating the @pokusew/pcsclite library in one of my components. I am using import * as pcsclite from "../../node_modules/@pokusew/pcsclite" to import ...

Adapting npm scripts with Node.js based on the current context

Can you set up package.json to execute a different npm start script depending on the context? For instance, I want to run DEBUG=http nodemon app.js during development. However, I prefer to run node app.js in production. ...

What is the reason that control flow analysis does not support the never type?

Here is the scenario I'm dealing with (utilizing strictNullChecks): function neverReturns(): never { throw new Error(); } const maybeString: string | null = Math.random() > 0.5 ? "hi" : null; if (!maybeString) { neverReturns(); // th ...

Can you provide guidance on how to access my account using the code that I have?

I'm having trouble getting the login functionality to work properly with this code. When I click the login button, nothing happens - no errors are displayed either. Can you help me identify what might be causing this issue? login() { var url = &ap ...