From d346b45e6e9f9fc29bab1bc0edd486fd3e6965d1 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 10 Sep 2025 14:49:29 -0700 Subject: [PATCH 1/2] Test --- internal/execute/tsctests/tsc_test.go | 28 ++++ ...there-is-bind-diagnostics-thats-ignored.js | 147 ++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 testdata/baselines/reference/tsc/incremental/when-there-is-bind-diagnostics-thats-ignored.js diff --git a/internal/execute/tsctests/tsc_test.go b/internal/execute/tsctests/tsc_test.go index b9a88f6196..e145bf178b 100644 --- a/internal/execute/tsctests/tsc_test.go +++ b/internal/execute/tsctests/tsc_test.go @@ -1602,6 +1602,34 @@ func TestTscIncremental(t *testing.T) { }, }, }, + { + subScenario: "when there is bind diagnostics thats ignored", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(` + { + "compilerOptions": { + "skipLibCheck": true, + "incremental": true, + } + }`), + "/home/src/workspaces/project/a.ts": `export const a = 10;`, + "/home/src/workspaces/project/b.d.ts": stringtestutil.Dedent(` + interface NoName { + Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => { + stop: () => Promise; + }; + } + `), + }, + commandLineArgs: []string{""}, + edits: []*tscEdit{ + noChange, + { + caption: "no change and tsc -b", + commandLineArgs: []string{"-b", "-v"}, + }, + }, + }, } for _, test := range testCases { diff --git a/testdata/baselines/reference/tsc/incremental/when-there-is-bind-diagnostics-thats-ignored.js b/testdata/baselines/reference/tsc/incremental/when-there-is-bind-diagnostics-thats-ignored.js new file mode 100644 index 0000000000..e8616777fb --- /dev/null +++ b/testdata/baselines/reference/tsc/incremental/when-there-is-bind-diagnostics-thats-ignored.js @@ -0,0 +1,147 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/a.ts] *new* +export const a = 10; +//// [/home/src/workspaces/project/b.d.ts] *new* +interface NoName { + Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => { + stop: () => Promise; + }; +} +//// [/home/src/workspaces/project/tsconfig.json] *new* +{ + "compilerOptions": { + "skipLibCheck": true, + "incremental": true, + } +} + +tsgo +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; +//// [/home/src/workspaces/project/a.js] *new* +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.a = void 0; +exports.a = 10; + +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* +{"version":"FakeTSVersion","errors":true,"root":[[2,3]],"fileNames":["lib.d.ts","./a.ts","./b.d.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"3a1e9965f8602302ee6ae53756eac8be-export const a = 10;",{"version":"53a40371b72faeca3dac96d61d6fb24f-interface NoName {\n Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {\n stop: () => Promise;\n };\n}","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"skipLibCheck":true}} +//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* +{ + "version": "FakeTSVersion", + "errors": true, + "root": [ + { + "files": [ + "./a.ts", + "./b.d.ts" + ], + "original": [ + 2, + 3 + ] + } + ], + "fileNames": [ + "lib.d.ts", + "./a.ts", + "./b.d.ts" + ], + "fileInfos": [ + { + "fileName": "lib.d.ts", + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "signature": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + }, + { + "fileName": "./a.ts", + "version": "3a1e9965f8602302ee6ae53756eac8be-export const a = 10;", + "signature": "3a1e9965f8602302ee6ae53756eac8be-export const a = 10;", + "impliedNodeFormat": "CommonJS" + }, + { + "fileName": "./b.d.ts", + "version": "53a40371b72faeca3dac96d61d6fb24f-interface NoName {\n Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {\n stop: () => Promise;\n };\n}", + "signature": "53a40371b72faeca3dac96d61d6fb24f-interface NoName {\n Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {\n stop: () => Promise;\n };\n}", + "affectsGlobalScope": true, + "impliedNodeFormat": "CommonJS", + "original": { + "version": "53a40371b72faeca3dac96d61d6fb24f-interface NoName {\n Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {\n stop: () => Promise;\n };\n}", + "affectsGlobalScope": true, + "impliedNodeFormat": 1 + } + } + ], + "options": { + "skipLibCheck": true + }, + "size": 1209 +} + +tsconfig.json:: +SemanticDiagnostics:: +*refresh* /home/src/tslibs/TS/Lib/lib.d.ts +*refresh* /home/src/workspaces/project/a.ts +*refresh* /home/src/workspaces/project/b.d.ts +Signatures:: + + +Edit [0]:: no change + +tsgo +ExitStatus:: Success +Output:: + +tsconfig.json:: +SemanticDiagnostics:: +Signatures:: + + +Edit [1]:: no change and tsc -b + +tsgo -b -v +ExitStatus:: Success +Output:: +[HH:MM:SS AM] Projects in this build: + * tsconfig.json + +[HH:MM:SS AM] Project 'tsconfig.json' is out of date because buildinfo file 'tsconfig.tsbuildinfo' indicates that program needs to report errors. + +[HH:MM:SS AM] Building project 'tsconfig.json'... + + +tsconfig.json:: +SemanticDiagnostics:: +Signatures:: From b6521fddb055afe267c25ab2f8251337a0f0a87e Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 10 Sep 2025 14:52:05 -0700 Subject: [PATCH 2/2] dont use bind diagnostics to determine if "errors" need to be recorded as they are computed as part of semantic diagnostics and cached --- internal/execute/incremental/program.go | 1 - .../when-there-is-bind-diagnostics-thats-ignored.js | 12 +++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/internal/execute/incremental/program.go b/internal/execute/incremental/program.go index 1512126297..2d306c27bd 100644 --- a/internal/execute/incremental/program.go +++ b/internal/execute/incremental/program.go @@ -320,7 +320,6 @@ func (p *Program) ensureHasErrorsForState(ctx context.Context, program *compiler len(program.GetConfigFileParsingDiagnostics()) > 0 || len(program.GetSyntacticDiagnostics(ctx, nil)) > 0 || len(program.GetProgramDiagnostics()) > 0 || - len(program.GetBindDiagnostics(ctx, nil)) > 0 || len(program.GetOptionsDiagnostics(ctx)) > 0 || len(program.GetGlobalDiagnostics(ctx)) > 0 { p.snapshot.hasErrors = core.TSTrue diff --git a/testdata/baselines/reference/tsc/incremental/when-there-is-bind-diagnostics-thats-ignored.js b/testdata/baselines/reference/tsc/incremental/when-there-is-bind-diagnostics-thats-ignored.js index e8616777fb..d6a1cd1182 100644 --- a/testdata/baselines/reference/tsc/incremental/when-there-is-bind-diagnostics-thats-ignored.js +++ b/testdata/baselines/reference/tsc/incremental/when-there-is-bind-diagnostics-thats-ignored.js @@ -50,11 +50,10 @@ exports.a = void 0; exports.a = 10; //// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","errors":true,"root":[[2,3]],"fileNames":["lib.d.ts","./a.ts","./b.d.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"3a1e9965f8602302ee6ae53756eac8be-export const a = 10;",{"version":"53a40371b72faeca3dac96d61d6fb24f-interface NoName {\n Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {\n stop: () => Promise;\n };\n}","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"skipLibCheck":true}} +{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","./a.ts","./b.d.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},"3a1e9965f8602302ee6ae53756eac8be-export const a = 10;",{"version":"53a40371b72faeca3dac96d61d6fb24f-interface NoName {\n Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {\n stop: () => Promise;\n };\n}","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"skipLibCheck":true}} //// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", - "errors": true, "root": [ { "files": [ @@ -107,7 +106,7 @@ exports.a = 10; "options": { "skipLibCheck": true }, - "size": 1209 + "size": 1195 } tsconfig.json:: @@ -137,11 +136,6 @@ Output:: [HH:MM:SS AM] Projects in this build: * tsconfig.json -[HH:MM:SS AM] Project 'tsconfig.json' is out of date because buildinfo file 'tsconfig.tsbuildinfo' indicates that program needs to report errors. +[HH:MM:SS AM] Project 'tsconfig.json' is up to date because newest input 'b.d.ts' is older than output 'tsconfig.tsbuildinfo' -[HH:MM:SS AM] Building project 'tsconfig.json'... - -tsconfig.json:: -SemanticDiagnostics:: -Signatures::