Skip to content

Typescript watch compiles each edited file twiceΒ #51611

Closed
@eladstr

Description

@eladstr

Bug Report

πŸ”Ž Search Terms

Typescript watch triggers multiple compilations

πŸ•— Version & Regression Information

This changed when moving from Typescript version 4.8.4 to 4.9.3

Reviewed: #37994

⏯ Demonstration Video

Screen.Recording.2022-11-21.at.12.46.08.mov

πŸ’» Code

package.json

{
"name": "testtsc",
"version": "1.0.0",
"description": "Test double compilation of TypeScript files",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "Elad Stern",
"license": "ISC",
"dependencies": {
"typescript": "^4.9.3"
}
}

main.ts

let a: string = "123456790123";
alert(a.slice(0, 2));

πŸ™ Actual behavior

In terminal, invoking npx and then tsc main.ts --watch, changing the source code of main.ts triggers Typescript watch to compile the file again - not once, but twice. The same took place in larger projects - double compilation of changed files, with one or two seconds in between.

πŸ™‚ Expected behavior

Once a source code file has been changed, it should compile only once by tsc watch, not twice.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions