Is TSC_WATCH utilizing the TSC_NONPOLLING_WATCHER?

Currently, I am engaged in a microservice integration project where I simultaneously run 8 typescript services using the command

tsc-watch --preserveWatchOutput --onSuccess 'node build/index.js'
.

Surprisingly, these processes are utilizing 70% of my CPU power even when no changes are being made to the source code. After some research, I discovered that there might be continuous polling for changes happening in the background. In an attempt to stop this unnecessary polling, I tried setting the environment variable TSC_NONPOLLING_WATCHER to "1" based on a helpful hint found at: https://medium.com/@julioromano/writing-typescript-on-a-laptop-this-might-improve-your-battery-life-f503dd16f019

Unfortunately, this adjustment did not seem to have any effect. Moreover, the author mentioned using "tsc -w" instead of tsc-watch, leading me to question the difference between tsc -w and tsc-watch.

If anyone could provide further insight or assistance regarding this matter, I would greatly appreciate it.

Answer №1

Update 1 no changes needed in tsconfig.json

I encountered a similar issue and plan to resolve it by correctly setting the environment variable

TSC_NONPOLLING_WATCHER="1"
.

In my situation, I had to modify .zprofile by adding:

export TSC_NONPOLLING_WATCHER="1"

You can verify it in a command prompt using echo $TSC_NONPOLLING_WATCHER.

Alternative Approach

If this solution does not work, try adjusting the tsconfig.json files as shown below:

"watchOptions": {
    // Use native file system events for files and directories
    "watchFile": "useFsEvents",
    "watchDirectory": "useFsEvents",

    // Poll files for updates more frequently
    // when they're updated frequently.
    "fallbackPolling": "dynamicPriority"
}

These guidelines are sourced from: https://www.typescriptlang.org/docs/handbook/configuring-watch.html and it is recommended to review them before making any modifications.

tsc vs tsc-watch

Regarding the distinction between tsc -w and tsc-watch, the project on GitHub states:

  • tsc-watch utilizes the current TypeScript compiler that is installed.
  • tsc-watch does not alter the compiler but simply adds new arguments, resulting in identical compilation, while all other arguments remain unchanged.

Hence, any configurations set for tsc should function similarly in tsc-watch within your particular scenario.

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

Tips for sorting/merging/consolidating data in Angular

Take a look at this code snippet: rowData = [ [ '2019-12-10 08:00:00', '2019-12-10 08:00:00', '2019-12-10 08:00:00', '2019-12-10 08:00:00', '2019-12-10 08:00:00', '2018-12-10 08:00:00' ...

Vue.js: Resolving the "Unknown Custom Element" Issue with Hot Module Replacement

I have a good understanding of component registration, but I am encountering a challenging issue: Vue.js component Unknown custom element Unknown custom element when nesting components in Vue.js The Issue at Hand While using the development server, I ...

The type Observable<any> cannot be assigned to Observable<any> type

I am currently working with angular 5 and ionic 3. I have defined an interface: export interface IAny { getDataSource: Observable<any>; } Components that implement this interface must have the following method: getDataSource () { return ...

Issue: This error occurs when attempting to double click on the diagram or a node but the show function for c is not recognized

I've encountered an issue with my gojs diagram. When I double click on it to edit the node name, I receive an error message. This problem occurred after upgrading my gojs version from v1.7.14 to v2.2.17. Below is the error stack trace: core.mjs:8453 E ...

Encountering the error message "Error: 'preserveValueImports' is an unknown compiler option" while setting up a SvelteKit project

https://i.stack.imgur.com/fnidk.png Every time I set up a new sveltekit project using TypeScript, I keep encountering the error "Unknown compiler option 'preserveValueImports'.ts" in the tsconfig.json file. The error shows up above the line wher ...

Guide on integrating an element into a different element in a Vue 3 Tree Viewer

In my current setup, I've implemented a TreeView component that holds a tree. Each tree entry includes Children with their own unique label, perm, and further children. Take a look at an example of the tree: App.vue let tree = ref({ label: 'o ...

Exceeded maximum stack size error encountered in Ionic 2 Tab bar functionality

When I attempt to incorporate a tab bar into my application, an error message saying "Maximum call stack size exceeded" is displayed Profile.html <ion-tabs> <ion-tab tabIcon="water" tabTitle="Water" ></ion-tab> <ion-tab tabI ...

To properly format the date value from the ngModel in Angular before sending it to the payload, I require the date to be in the format

When working with Angular 9, I am facing an issue where I need to format and send my date in a specific way within the payload. Currently, the code is sending the date in this format: otgStartDate: 2021-07-20T09:56:39.000Z, but I actually want it to be for ...

Determine the associated value for a given key within a TypeScript object

I have a structure like this: type newsItem = { img: string; slug: newsSlug; text: newsText; }; derived from an enum like this: export const newsEnum = { interesting: "Interesting", regions: "Regions", contradictory: " ...

Ensuring Mongoose Schema complies with an external API

My database schema includes a mongoose User schema with the following structure: const User: Schema = new Schema({ // some other fields email: {type: String, unique: true, require: true, validate: [myValidator, 'invalid email provided'], // some ...

This error occurred: "Property 'release' cannot be read because it is undefined."

Hello everyone! I'm in need of some assistance. I am trying to test my service tree with a specific structure. Here is an overview of my test: describe(`Service selector`, () => { describe(`getCurrentServiceTree`, () => { it(`should bui ...

Issue with JQuery Promise: fail() being invoked before promise resolution

In my TypeScript code, I encountered a peculiar issue with a jQuery promise. The fail() function is being executed immediately, logging an error message to the console, despite the promise resolving successfully afterwards. Here is the code snippet: ...

Is there a way to combine compiling TypeScript and running the resulting .js file into one build command in Sublime Text 3?

I have successfully installed the TypeScript plugin on Sublime Text 3. Once installed, a build system is added to the menu for easy access. https://i.stack.imgur.com/m21bT.png You can simply press "Command + B" to build a .ts file. My goal is to compile ...

Utilizing external JavaScript scripts within TypeScript

If I have a JavaScript file named myScript.js containing the following code: function run(file) { // some operations } How can I incorporate the 'run' function into a TypeScript file? I've come across similar inquiries, but the respon ...

Typescript is facing an issue locating the declaration file

I'm encountering an issue with TypeScript not recognizing my declaration file, even though it exists. Can anyone provide insight into why this might be happening? Here is the structure of my project: scr - main.ts - dec.d.ts str-utils - index. ...

Are there any browser-compatible Kafka client libraries available?

I recently completed an Angular 4 project utilizing Typescript and Angular-cli. Now, I am looking to send messages to a Kakfa broker located on another machine using a JavaScript/Typescript Kafka client library. Unfortunately, the kafka-node and no-kafka ...

Using the -t or --testNamePattern in Jest will execute all tests

Currently, I have set up my testing framework using jest and ts-jest based on the guidelines provided by the ts-jest documentation. When I execute the command yarn test --listTests, I can identify the specific test file I intend to run: processNewUser.ts ...

core.js:12853 Error encountered when trying to use 'ngIf' on a 'div' element that is not recognized as a valid property

I am currently utilizing Angular 9. and I am faced with a scenario where I need to load dynamic components Within one of my components, I encountered the following warning core.js:12853 Can't bind to 'ngIf' since it isn't a known pro ...

Initialization of an empty array in Typescript

My promises array is structured as follows: export type PromisesArray = [ Promise<IApplicant> | null, Promise<ICampaign | ICampaignLight> | null, Promise<IApplication[]> | null, Promise<IComment[]> | null, Promise<{ st ...

The Ionic project compilation was unsuccessful

Issue: This module is defined using 'export =', and can only be utilized with a default import if the 'allowSyntheticDefaultImports' flag is enabled. Error found in the file: 1 import FormData from "form-data"; ~~~~~~~~ node ...