Is it possible to utilize tsc --watch exclusively for type checking alongside esbuild?

When I execute tsc --noEmit --incremental, it takes approximately 17 seconds to complete. To improve the speed, tsc provides watch mode which now only takes around 2 seconds.

This is my current script:

// type checking
tsc --noEmit --incremental

// build
node ./build-with-esbuild.js

The build script itself has its own watcher. How can I incorporate tsc --watch with my build script?

Answer №1

After successfully implementing stdio pipe and detecting tsc, I have completed my solution. I made the decision to remove the watcher from the build process and now solely depend on the tsc watcher.

import { execSync, spawn } from 'child_process';

const tschecking = spawn(
    `npx tsc --watch --incremental --tsBuildInfoFile ${DIR}/tsconfig.tsbuildinfo`,
    [],
    {
        cwd: SERVICE_DIR,
        stdio: 'pipe',
        shell: true,
    }
);

/**
 * Execute build once type checking is done
 */
tschecking.stdout.on('data', (data: any): any => {
    const output = data.toString();
    console.log(output);
    if (output.includes('Watching for file changes')) {
        build();
    }
});

Answer №2

If you're looking for an alternative approach, consider leveraging a tool such as concurrently to simultaneously execute both the tsc command and the build script:

concurrently "tsc --watch --incremental" "node build.js"

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

Deactivate multiple textareas within a loop by utilizing JQuery/Typescript and KnockoutJS

I am working on a for loop that generates a series of textareas with unique ids using KO data-binding, but they all share the same name. My goal is to utilize Jquery to determine if all the textareas in the list are empty. If they are, I want to disable al ...

Varieties of data classifications for the information obtained from supabase

1 I'm encountering an issue while attempting to define the data types from Supabase. I received an error message stating: "type '{ id: string; title: string; capacity: number | null; start_date: Date | null; start_time: string | null; end_ ...

What is the best approach for managing _app.js props when transitioning from a page router to an app router?

Recently, in the latest version of next.js 13.4, the app router has been upgraded to stable. This update prompted me to transition my existing page router to utilize the app router. In _app.jsx file, it is expected to receive Component and pageProps as pr ...

Error: The render view is unable to read the 'vote' property of a null object

Within this component, I am receiving a Promise object in the properties. I attempt to store it in state, but upon rendering the view, I encounter the error message "TypeError: Cannot read property 'vote' of null." Seeking a solution to my predic ...

Leveraging React version 15 within Piral

The application currently in production utilizes React 15 and upgrading to the latest version, React 16, is not an immediate option. Looking ahead, I plan to incorporate piral as a whole, however, piral requires React 16 and I am unsure how to integrate R ...

Modifying a group of Components in Angular using a Service

Managing a set of Components involves changing their properties using a Service. The Components have a minimal model and are meant to remain compact. They are being rendered with *ngFor. The Service possesses a large Object and should possess the abilit ...

Is it okay for a function to be 'awaited' in TypeScript without causing an error?

Waiting for a function that is not even called is a futile endeavor. Surprisingly, neither a compile time error nor a runtime error is generated in such cases. The perplexing question remains - in what scenarios would one wait for a function to be execut ...

What could be causing components to fail to rerender despite the change in state and even the use of a new

I am currently working with a custom tab component that allows navigation between tabs in a specific format. One of the tabs contains buttons that are also intended to navigate to these other tabs (even though I cannot modify the content). Here is an exam ...

Is it possible to choose a range in ion2-calendar starting from the day after tomorrow and spanning three months ahead?

Currently, I have set up an ion-calendar utilizing the ion2-calendar plugin. The calendar is configured to disable dates prior to today's date. However, my goal is to also disable "today" and display available dates starting from tomorrow. Additionall ...

What is the correct way to set up Typescript with external packages for Internet Explorer 11 using Babel 7 and Webpack 4?

After releasing a new version of our react app, we encountered an issue with IE11 complaining about the use of the let keyword. Upon investigation, we discovered that upgrading the query-string package from version 5.1.0 to 6.4.0 introduced the usage of th ...

Children must be matched to the route before navigating to it

Hello there! I'm having trouble understanding how to navigate new routes with children in Angular 2 rc 4. I'm trying to route to the TestComponent, which has a child, but I keep getting an error message saying "cannot match any route 'test&a ...

Is it feasible to alter the file name while utilizing express-fileUpload library?

Is there a way to modify the file name of an uploaded file on the server side? app.post(URL, (req, res) => { let fileName = req.files.file.name; req.fileUpload; res.statusCode = HTTP_OK; res.send("Good Job") }) The settings I have in uploadF ...

What is the best way to preserve an enumeration value in TypeScript?

Is there a way to save enumeration values in TypeScript? For instance: createArticle(name: string, clr: ??enumeration??) { return axios.post(`${environment.apiUrl}/cards`, { card: `${name}`, color: ??clr?? }, ... } PS: Conte ...

Unable to retrieve a string from one function within another function

Three functions are responsible for triggering POST API calls, with the intention of returning a success or failure message to whoever invokes them (Observable<string>). In an effort to avoid repetition, I introduced a new function to retrieve succe ...

In the event that you encounter various version formats during your work

Suppose I have a number in the format Example "1.0.0.0". If I want to increase it to the next version, it would be "1.0.0.1" By using the following regex code snippet, we can achieve this perfect result of incrementing the version to "1.0.0.1": let ver ...

Resolving NgModule Import Errors During Migration of Angular Project from Version 11 to 16

Currently, I am in the process of upgrading an existing Angular project from version 11 to version 16. The update went smoothly until I encountered a roadblock upon reaching version 16. The main issue I am facing is that most of my modules are displaying ...

How come the hasOwnProperty function does not remove objects of type {}?

I am working with a complex type called ReactNode from the version @types/react 16.9.17 and TypeScript v3.7.4. import React, { ReactNode } from 'react'; My goal is to reduce this type to a new type that includes the property children. To achie ...

React refs should always be validated for null or never values to avoid any potential issues

As I set up a react ref to be used in useEffect, the compiler is throwing an error stating that myRef.current evaluates to never: import React, {useRef, useState} from 'react' export default function RefProblem() { const myRef = useRef(null ...

What is the reason for TypeScript not displaying a type mismatch error in this particular instance?

After starting to use React with TypeScript, I defined my types as follows: type CardInfo = { cardIndex: null | number; title: string; note: string; _id: string; from: string; cardId: string; }; type ContentType = { title: string; note: st ...

Node.js with TypeScript: The block-scoped variable 'events' cannot be redeclared

I am currently in the process of migrating a Node + ES6 project to TypeScript. My goal is to stick to ES6 (since I am using Node 7.x) and incorporate the use of Map. Upon running tsc -p, the following errors are displayed: src/actions.ts(3,9): error TS2 ...