Skip to content

Commit 806c619

Browse files
authored
Fix incorrectly encoded "errors" state in buildInfo by querying bind diagnostics (#1706)
1 parent fe41b2d commit 806c619

File tree

3 files changed

+169
-1
lines changed

3 files changed

+169
-1
lines changed

internal/execute/incremental/program.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ func (p *Program) ensureHasErrorsForState(ctx context.Context, program *compiler
320320
len(program.GetConfigFileParsingDiagnostics()) > 0 ||
321321
len(program.GetSyntacticDiagnostics(ctx, nil)) > 0 ||
322322
len(program.GetProgramDiagnostics()) > 0 ||
323-
len(program.GetBindDiagnostics(ctx, nil)) > 0 ||
324323
len(program.GetOptionsDiagnostics(ctx)) > 0 ||
325324
len(program.GetGlobalDiagnostics(ctx)) > 0 {
326325
p.snapshot.hasErrors = core.TSTrue

internal/execute/tsctests/tsc_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,34 @@ func TestTscIncremental(t *testing.T) {
16021602
},
16031603
},
16041604
},
1605+
{
1606+
subScenario: "when there is bind diagnostics thats ignored",
1607+
files: FileMap{
1608+
"/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(`
1609+
{
1610+
"compilerOptions": {
1611+
"skipLibCheck": true,
1612+
"incremental": true,
1613+
}
1614+
}`),
1615+
"/home/src/workspaces/project/a.ts": `export const a = 10;`,
1616+
"/home/src/workspaces/project/b.d.ts": stringtestutil.Dedent(`
1617+
interface NoName {
1618+
Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {
1619+
stop: () => Promise<any>;
1620+
};
1621+
}
1622+
`),
1623+
},
1624+
commandLineArgs: []string{""},
1625+
edits: []*tscEdit{
1626+
noChange,
1627+
{
1628+
caption: "no change and tsc -b",
1629+
commandLineArgs: []string{"-b", "-v"},
1630+
},
1631+
},
1632+
},
16051633
}
16061634

16071635
for _, test := range testCases {
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
currentDirectory::/home/src/workspaces/project
2+
useCaseSensitiveFileNames::true
3+
Input::
4+
//// [/home/src/workspaces/project/a.ts] *new*
5+
export const a = 10;
6+
//// [/home/src/workspaces/project/b.d.ts] *new*
7+
interface NoName {
8+
Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {
9+
stop: () => Promise<any>;
10+
};
11+
}
12+
//// [/home/src/workspaces/project/tsconfig.json] *new*
13+
{
14+
"compilerOptions": {
15+
"skipLibCheck": true,
16+
"incremental": true,
17+
}
18+
}
19+
20+
tsgo
21+
ExitStatus:: Success
22+
Output::
23+
//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib*
24+
/// <reference no-default-lib="true"/>
25+
interface Boolean {}
26+
interface Function {}
27+
interface CallableFunction {}
28+
interface NewableFunction {}
29+
interface IArguments {}
30+
interface Number { toExponential: any; }
31+
interface Object {}
32+
interface RegExp {}
33+
interface String { charAt: any; }
34+
interface Array<T> { length: number; [n: number]: T; }
35+
interface ReadonlyArray<T> {}
36+
interface SymbolConstructor {
37+
(desc?: string | number): symbol;
38+
for(name: string): symbol;
39+
readonly toStringTag: symbol;
40+
}
41+
declare var Symbol: SymbolConstructor;
42+
interface Symbol {
43+
readonly [Symbol.toStringTag]: string;
44+
}
45+
declare const console: { log(msg: any): void; };
46+
//// [/home/src/workspaces/project/a.js] *new*
47+
"use strict";
48+
Object.defineProperty(exports, "__esModule", { value: true });
49+
exports.a = void 0;
50+
exports.a = 10;
51+
52+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new*
53+
{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","./a.ts","./b.d.ts"],"fileInfos":[{"version":"8859c12c614ce56ba9a18e58384a198f-/// <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> {}\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<any>;\n };\n}","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"skipLibCheck":true}}
54+
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new*
55+
{
56+
"version": "FakeTSVersion",
57+
"root": [
58+
{
59+
"files": [
60+
"./a.ts",
61+
"./b.d.ts"
62+
],
63+
"original": [
64+
2,
65+
3
66+
]
67+
}
68+
],
69+
"fileNames": [
70+
"lib.d.ts",
71+
"./a.ts",
72+
"./b.d.ts"
73+
],
74+
"fileInfos": [
75+
{
76+
"fileName": "lib.d.ts",
77+
"version": "8859c12c614ce56ba9a18e58384a198f-/// <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> {}\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; };",
78+
"signature": "8859c12c614ce56ba9a18e58384a198f-/// <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> {}\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; };",
79+
"affectsGlobalScope": true,
80+
"impliedNodeFormat": "CommonJS",
81+
"original": {
82+
"version": "8859c12c614ce56ba9a18e58384a198f-/// <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> {}\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; };",
83+
"affectsGlobalScope": true,
84+
"impliedNodeFormat": 1
85+
}
86+
},
87+
{
88+
"fileName": "./a.ts",
89+
"version": "3a1e9965f8602302ee6ae53756eac8be-export const a = 10;",
90+
"signature": "3a1e9965f8602302ee6ae53756eac8be-export const a = 10;",
91+
"impliedNodeFormat": "CommonJS"
92+
},
93+
{
94+
"fileName": "./b.d.ts",
95+
"version": "53a40371b72faeca3dac96d61d6fb24f-interface NoName {\n Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {\n stop: () => Promise<any>;\n };\n}",
96+
"signature": "53a40371b72faeca3dac96d61d6fb24f-interface NoName {\n Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {\n stop: () => Promise<any>;\n };\n}",
97+
"affectsGlobalScope": true,
98+
"impliedNodeFormat": "CommonJS",
99+
"original": {
100+
"version": "53a40371b72faeca3dac96d61d6fb24f-interface NoName {\n Profiler: new ({ sampleInterval: number, maxBufferSize: number }) => {\n stop: () => Promise<any>;\n };\n}",
101+
"affectsGlobalScope": true,
102+
"impliedNodeFormat": 1
103+
}
104+
}
105+
],
106+
"options": {
107+
"skipLibCheck": true
108+
},
109+
"size": 1195
110+
}
111+
112+
tsconfig.json::
113+
SemanticDiagnostics::
114+
*refresh* /home/src/tslibs/TS/Lib/lib.d.ts
115+
*refresh* /home/src/workspaces/project/a.ts
116+
*refresh* /home/src/workspaces/project/b.d.ts
117+
Signatures::
118+
119+
120+
Edit [0]:: no change
121+
122+
tsgo
123+
ExitStatus:: Success
124+
Output::
125+
126+
tsconfig.json::
127+
SemanticDiagnostics::
128+
Signatures::
129+
130+
131+
Edit [1]:: no change and tsc -b
132+
133+
tsgo -b -v
134+
ExitStatus:: Success
135+
Output::
136+
[HH:MM:SS AM] Projects in this build:
137+
* tsconfig.json
138+
139+
[HH:MM:SS AM] Project 'tsconfig.json' is up to date because newest input 'b.d.ts' is older than output 'tsconfig.tsbuildinfo'
140+
141+

0 commit comments

Comments
 (0)