New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
During uptodate ness check with buildInfo, check if there are errors explicitly with noEmit #50974
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace ts { | ||
describe("unittests:: tsbuild:: noEmit", () => { | ||
function verifyNoEmitWorker(subScenario: string, aTsContent: string, commandLineArgs: readonly string[]) { | ||
verifyTscWithEdits({ | ||
scenario: "noEmit", | ||
subScenario, | ||
fs: () => loadProjectFromFiles({ | ||
"/src/a.ts": aTsContent, | ||
"/src/tsconfig.json": JSON.stringify({ | ||
compilerOptions: { noEmit: true } | ||
}) | ||
}), | ||
commandLineArgs, | ||
edits: [ | ||
noChangeRun, | ||
{ | ||
subScenario: "Fix error", | ||
modifyFs: fs => fs.writeFileSync("/src/a.ts", `const a = "hello"`), | ||
}, | ||
noChangeRun, | ||
], | ||
baselinePrograms: true, | ||
}); | ||
} | ||
|
||
function verifyNoEmit(subScenario: string, aTsContent: string) { | ||
verifyNoEmitWorker(subScenario, aTsContent, ["--b", "/src/tsconfig.json", "-v"]); | ||
verifyNoEmitWorker(`${subScenario} with incremental`, aTsContent, ["--b", "/src/tsconfig.json", "-v", "--incremental"]); | ||
} | ||
|
||
verifyNoEmit("syntax errors", `const a = "hello`); | ||
verifyNoEmit("semantic errors", `const a: number = "hello"`); | ||
}); | ||
} |
234 changes: 234 additions & 0 deletions
234
tests/baselines/reference/tsbuild/noEmit/semantic-errors-with-incremental.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
Input:: | ||
//// [/lib/lib.d.ts] | ||
/// <reference no-default-lib="true"/> | ||
interface Boolean {} | ||
interface Function {} | ||
interface CallableFunction {} | ||
interface NewableFunction {} | ||
interface IArguments {} | ||
interface Number { toExponential: any; } | ||
interface Object {} | ||
interface RegExp {} | ||
interface String { charAt: any; } | ||
interface Array<T> { length: number; [n: number]: T; } | ||
interface ReadonlyArray<T> {} | ||
declare const console: { log(msg: any): void; }; | ||
|
||
//// [/src/a.ts] | ||
const a: number = "hello" | ||
|
||
//// [/src/tsconfig.json] | ||
{"compilerOptions":{"noEmit":true}} | ||
|
||
|
||
|
||
Output:: | ||
/lib/tsc --b /src/tsconfig.json -v --incremental | ||
[[90m12:00:08 AM[0m] Projects in this build: | ||
* src/tsconfig.json | ||
|
||
[[90m12:00:09 AM[0m] Project 'src/tsconfig.json' is out of date because output file 'src/tsconfig.tsbuildinfo' does not exist | ||
|
||
[[90m12:00:10 AM[0m] Building project '/src/tsconfig.json'... | ||
|
||
[96msrc/a.ts[0m:[93m1[0m:[93m7[0m - [91merror[0m[90m TS2322: [0mType 'string' is not assignable to type 'number'. | ||
|
||
[7m1[0m const a: number = "hello" | ||
[7m [0m [91m ~[0m | ||
|
||
|
||
Found 1 error. | ||
|
||
exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped | ||
Program root files: ["/src/a.ts"] | ||
Program options: {"noEmit":true,"incremental":true,"configFilePath":"/src/tsconfig.json"} | ||
Program structureReused: Not | ||
Program files:: | ||
/lib/lib.d.ts | ||
/src/a.ts | ||
|
||
Semantic diagnostics in builder refreshed for:: | ||
/lib/lib.d.ts | ||
/src/a.ts | ||
|
||
Shape signatures in builder refreshed for:: | ||
/lib/lib.d.ts (used version) | ||
/src/a.ts (used version) | ||
|
||
|
||
//// [/src/tsconfig.tsbuildinfo] | ||
{"program":{"fileNames":["../lib/lib.d.ts","./a.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"1311033573-const a: number = \"hello\"","affectsGlobalScope":true}],"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,[2,[{"file":"./a.ts","start":6,"length":1,"code":2322,"category":1,"messageText":"Type 'string' is not assignable to type 'number'."}]]],"affectedFilesPendingEmit":[[2,1]]},"version":"FakeTSVersion"} | ||
|
||
//// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] | ||
{ | ||
"program": { | ||
"fileNames": [ | ||
"../lib/lib.d.ts", | ||
"./a.ts" | ||
], | ||
"fileInfos": { | ||
"../lib/lib.d.ts": { | ||
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };", | ||
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };", | ||
"affectsGlobalScope": true | ||
}, | ||
"./a.ts": { | ||
"version": "1311033573-const a: number = \"hello\"", | ||
"signature": "1311033573-const a: number = \"hello\"", | ||
"affectsGlobalScope": true | ||
} | ||
}, | ||
"referencedMap": {}, | ||
"exportedModulesMap": {}, | ||
"semanticDiagnosticsPerFile": [ | ||
"../lib/lib.d.ts", | ||
[ | ||
"./a.ts", | ||
[ | ||
{ | ||
"file": "./a.ts", | ||
"start": 6, | ||
"length": 1, | ||
"code": 2322, | ||
"category": 1, | ||
"messageText": "Type 'string' is not assignable to type 'number'." | ||
} | ||
] | ||
] | ||
], | ||
"affectedFilesPendingEmit": [ | ||
[ | ||
"./a.ts", | ||
"Full" | ||
] | ||
] | ||
}, | ||
"version": "FakeTSVersion", | ||
"size": 899 | ||
} | ||
|
||
|
||
|
||
Change:: no-change-run | ||
Input:: | ||
|
||
|
||
Output:: | ||
/lib/tsc --b /src/tsconfig.json -v --incremental | ||
[[90m12:00:14 AM[0m] Projects in this build: | ||
* src/tsconfig.json | ||
|
||
[[90m12:00:15 AM[0m] Project 'src/tsconfig.json' is out of date because buildinfo file 'src/tsconfig.tsbuildinfo' indicates that some of the changes were not emitted | ||
|
||
[[90m12:00:16 AM[0m] Building project '/src/tsconfig.json'... | ||
|
||
[96msrc/a.ts[0m:[93m1[0m:[93m7[0m - [91merror[0m[90m TS2322: [0mType 'string' is not assignable to type 'number'. | ||
|
||
[7m1[0m const a: number = "hello" | ||
[7m [0m [91m ~[0m | ||
|
||
|
||
Found 1 error. | ||
|
||
exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped | ||
Program root files: ["/src/a.ts"] | ||
Program options: {"noEmit":true,"incremental":true,"configFilePath":"/src/tsconfig.json"} | ||
Program structureReused: Not | ||
Program files:: | ||
/lib/lib.d.ts | ||
/src/a.ts | ||
|
||
Semantic diagnostics in builder refreshed for:: | ||
|
||
No shapes updated in the builder:: | ||
|
||
|
||
|
||
|
||
Change:: Fix error | ||
Input:: | ||
//// [/src/a.ts] | ||
const a = "hello" | ||
|
||
|
||
|
||
Output:: | ||
/lib/tsc --b /src/tsconfig.json -v --incremental | ||
[[90m12:00:18 AM[0m] Projects in this build: | ||
* src/tsconfig.json | ||
|
||
[[90m12:00:19 AM[0m] Project 'src/tsconfig.json' is out of date because buildinfo file 'src/tsconfig.tsbuildinfo' indicates that some of the changes were not emitted | ||
|
||
[[90m12:00:20 AM[0m] Building project '/src/tsconfig.json'... | ||
|
||
exitCode:: ExitStatus.Success | ||
Program root files: ["/src/a.ts"] | ||
Program options: {"noEmit":true,"incremental":true,"configFilePath":"/src/tsconfig.json"} | ||
Program structureReused: Not | ||
Program files:: | ||
/lib/lib.d.ts | ||
/src/a.ts | ||
|
||
Semantic diagnostics in builder refreshed for:: | ||
/lib/lib.d.ts | ||
/src/a.ts | ||
|
||
Shape signatures in builder refreshed for:: | ||
/src/a.ts (computed .d.ts) | ||
|
||
|
||
//// [/src/tsconfig.tsbuildinfo] | ||
{"program":{"fileNames":["../lib/lib.d.ts","./a.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"4011451714-const a = \"hello\"","signature":"-4100694204-declare const a = \"hello\";\r\n","affectsGlobalScope":true}],"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2],"affectedFilesPendingEmit":[[2,1]]},"version":"FakeTSVersion"} | ||
|
||
//// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] | ||
{ | ||
"program": { | ||
"fileNames": [ | ||
"../lib/lib.d.ts", | ||
"./a.ts" | ||
], | ||
"fileInfos": { | ||
"../lib/lib.d.ts": { | ||
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };", | ||
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };", | ||
"affectsGlobalScope": true | ||
}, | ||
"./a.ts": { | ||
"version": "4011451714-const a = \"hello\"", | ||
"signature": "-4100694204-declare const a = \"hello\";\r\n", | ||
"affectsGlobalScope": true | ||
} | ||
}, | ||
"referencedMap": {}, | ||
"exportedModulesMap": {}, | ||
"semanticDiagnosticsPerFile": [ | ||
"../lib/lib.d.ts", | ||
"./a.ts" | ||
], | ||
"affectedFilesPendingEmit": [ | ||
[ | ||
"./a.ts", | ||
"Full" | ||
] | ||
] | ||
}, | ||
"version": "FakeTSVersion", | ||
"size": 816 | ||
} | ||
|
||
|
||
|
||
Change:: no-change-run | ||
Input:: | ||
|
||
|
||
Output:: | ||
/lib/tsc --b /src/tsconfig.json -v --incremental | ||
[[90m12:00:24 AM[0m] Projects in this build: | ||
* src/tsconfig.json | ||
|
||
[[90m12:00:25 AM[0m] Project 'src/tsconfig.json' is up to date because newest input 'src/a.ts' is older than output 'src/tsconfig.tsbuildinfo' | ||
|
||
exitCode:: ExitStatus.Success | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helps me understand why
affectedFilesPendingEmit
behaves differently undernoEmit
, but I don’t understand why that makes checking for the presence of semantic errors the correct fallback. Why does the presence of semantic errors definitely mean the buildinfo is out of date? Why isn’t the same true of syntactic errors?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If program has syntactic errors the
changeFileSet
because semantic diagnostics are not even processed in that case and state remains same. (https://github.com/microsoft/TypeScript/pull/50974/files#diff-2461280d51916bf4023650d8950c0af3bf16011e3f0c8a290c7c9f70056147a0R77) I will update the comment