Skip to content

Commit 4d34bc7

Browse files
committed
dts emit is pending when dts errors are pending, do not clean emit diagnostics if dts errors are not pending
1 parent 2e55292 commit 4d34bc7

5 files changed

+510
-240
lines changed

internal/incremental/snapshot.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func getPendingEmitKind(emitKind FileEmitKind, oldEmitKind FileEmitKind) FileEmi
9696
}
9797
// If dts errors pending, add dts errors flag
9898
if (diff & FileEmitKindDtsErrors) != 0 {
99-
result |= emitKind & FileEmitKindDtsErrors
99+
result |= emitKind & FileEmitKindAllDts
100100
}
101101
// If there is diff in Dts emit, pending emit is dts emit flags
102102
if (diff & FileEmitKindAllDtsEmit) != 0 {
@@ -239,7 +239,9 @@ func (s *snapshot) addFileToChangeSet(filePath tspath.Path) {
239239
func (s *snapshot) addFileToAffectedFilesPendingEmit(filePath tspath.Path, emitKind FileEmitKind) {
240240
existingKind, _ := s.affectedFilesPendingEmit.Load(filePath)
241241
s.affectedFilesPendingEmit.Store(filePath, existingKind|emitKind)
242-
s.emitDiagnosticsPerFile.Delete(filePath)
242+
if emitKind&FileEmitKindDtsErrors != 0 {
243+
s.emitDiagnosticsPerFile.Delete(filePath)
244+
}
243245
s.buildInfoEmitPending.Store(true)
244246
}
245247

testdata/baselines/reference/tsbuild/noEmit/dts-errors-with-declaration-enable-changes-with-incremental-as-modules.js

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Signatures::
256256
Edit [2]:: With declaration and declarationMap noEmit - Should report errors
257257

258258
tsgo -b -v --noEmit --declaration --declarationMap
259-
ExitStatus:: Success
259+
ExitStatus:: DiagnosticsPresent_OutputsSkipped
260260
Output::
261261
[HH:MM:SS AM] Projects in this build:
262262
* tsconfig.json
@@ -265,8 +265,20 @@ Output::
265265

266266
[HH:MM:SS AM] Building project 'tsconfig.json'...
267267

268+
a.ts:1:14 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected.
269+
270+
1 export const a = class { private p = 10; };
271+
   ~
272+
273+
a.ts:1:14 - Add a type annotation to the variable a.
274+
1 export const a = class { private p = 10; };
275+
   ~
276+
277+
278+
Found 1 error in a.ts:1
279+
268280
//// [/home/src/projects/project/tsconfig.tsbuildinfo] *modified*
269-
{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","./a.ts","./b.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},"9c1fc7106f3a21aadb5219db8b3209bc-export const a = class { private p = 10; };","907abc8137ceb88f0ddd6eccfa92d573-export const b = 10;"],"options":{"declaration":true,"declarationMap":true},"affectedFilesPendingEmit":[[2,49],[3,49]]}
281+
{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.d.ts","./a.ts","./b.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},"9c1fc7106f3a21aadb5219db8b3209bc-export const a = class { private p = 10; };","907abc8137ceb88f0ddd6eccfa92d573-export const b = 10;"],"options":{"declaration":true,"declarationMap":true},"emitDiagnosticsPerFile":[[2,[{"pos":13,"end":14,"code":4094,"category":1,"message":"Property 'p' of exported anonymous class type may not be private or protected.","relatedInformation":[{"pos":13,"end":14,"code":9027,"category":1,"message":"Add a type annotation to the variable a."}]}]]],"affectedFilesPendingEmit":[[2,49],[3,49]]}
270282
//// [/home/src/projects/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified*
271283
{
272284
"version": "FakeTSVersion",
@@ -317,6 +329,29 @@ Output::
317329
"declaration": true,
318330
"declarationMap": true
319331
},
332+
"emitDiagnosticsPerFile": [
333+
[
334+
"./a.ts",
335+
[
336+
{
337+
"pos": 13,
338+
"end": 14,
339+
"code": 4094,
340+
"category": 1,
341+
"message": "Property 'p' of exported anonymous class type may not be private or protected.",
342+
"relatedInformation": [
343+
{
344+
"pos": 13,
345+
"end": 14,
346+
"code": 9027,
347+
"category": 1,
348+
"message": "Add a type annotation to the variable a."
349+
}
350+
]
351+
}
352+
]
353+
]
354+
],
320355
"affectedFilesPendingEmit": [
321356
[
322357
"./a.ts",
@@ -335,31 +370,14 @@ Output::
335370
]
336371
]
337372
],
338-
"size": 1100
373+
"size": 1390
339374
}
340375

341376
tsconfig.json::
342377
SemanticDiagnostics::
343378
Signatures::
344379

345380

346-
Diff:: !!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!
347-
--- nonIncremental.output.txt
348-
+++ incremental.output.txt
349-
@@ -1,12 +0,0 @@
350-
-a.ts:1:14 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected.
351-
-
352-
-1 export const a = class { private p = 10; };
353-
-   ~
354-
-
355-
- a.ts:1:14 - Add a type annotation to the variable a.
356-
- 1 export const a = class { private p = 10; };
357-
-    ~
358-
-
359-
-
360-
-Found 1 error in a.ts:1
361-
-
362-
363381
Edit [3]:: no change
364382

365383
tsgo -b -v --noEmit
@@ -381,7 +399,7 @@ Output::
381399
[HH:MM:SS AM] Projects in this build:
382400
* tsconfig.json
383401

384-
[[90mHH:MM:SS AM[0m] Project 'tsconfig.json' is out of date because buildinfo file 'tsconfig.tsbuildinfo' indicates that some of the changes were not emitted
402+
[[90mHH:MM:SS AM[0m] Project 'tsconfig.json' is out of date because buildinfo file 'tsconfig.tsbuildinfo' indicates that program needs to report errors.
385403

386404
[HH:MM:SS AM] Building project 'tsconfig.json'...
387405

testdata/baselines/reference/tsbuild/noEmit/dts-errors-with-declaration-enable-changes-with-incremental.js

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Signatures::
230230
Edit [2]:: With declaration and declarationMap noEmit - Should report errors
231231

232232
tsgo -b -v --noEmit --declaration --declarationMap
233-
ExitStatus:: Success
233+
ExitStatus:: DiagnosticsPresent_OutputsSkipped
234234
Output::
235235
[HH:MM:SS AM] Projects in this build:
236236
* tsconfig.json
@@ -239,8 +239,20 @@ Output::
239239

240240
[HH:MM:SS AM] Building project 'tsconfig.json'...
241241

242+
a.ts:1:7 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected.
243+
244+
1 const a = class { private p = 10; };
245+
   ~
246+
247+
a.ts:1:7 - Add a type annotation to the variable a.
248+
1 const a = class { private p = 10; };
249+
   ~
250+
251+
252+
Found 1 error in a.ts:1
253+
242254
//// [/home/src/projects/project/tsconfig.tsbuildinfo] *modified*
243-
{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./a.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},{"version":"54435c7adb578d59d7e39dd2f567250e-const a = class { private p = 10; };","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"declaration":true,"declarationMap":true},"affectedFilesPendingEmit":[[2,49]]}
255+
{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","./a.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},{"version":"54435c7adb578d59d7e39dd2f567250e-const a = class { private p = 10; };","affectsGlobalScope":true,"impliedNodeFormat":1}],"options":{"declaration":true,"declarationMap":true},"emitDiagnosticsPerFile":[[2,[{"pos":6,"end":7,"code":4094,"category":1,"message":"Property 'p' of exported anonymous class type may not be private or protected.","relatedInformation":[{"pos":6,"end":7,"code":9027,"category":1,"message":"Add a type annotation to the variable a."}]}]]],"affectedFilesPendingEmit":[[2,49]]}
244256
//// [/home/src/projects/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified*
245257
{
246258
"version": "FakeTSVersion",
@@ -286,6 +298,29 @@ Output::
286298
"declaration": true,
287299
"declarationMap": true
288300
},
301+
"emitDiagnosticsPerFile": [
302+
[
303+
"./a.ts",
304+
[
305+
{
306+
"pos": 6,
307+
"end": 7,
308+
"code": 4094,
309+
"category": 1,
310+
"message": "Property 'p' of exported anonymous class type may not be private or protected.",
311+
"relatedInformation": [
312+
{
313+
"pos": 6,
314+
"end": 7,
315+
"code": 9027,
316+
"category": 1,
317+
"message": "Add a type annotation to the variable a."
318+
}
319+
]
320+
}
321+
]
322+
]
323+
],
289324
"affectedFilesPendingEmit": [
290325
[
291326
"./a.ts",
@@ -296,31 +331,14 @@ Output::
296331
]
297332
]
298333
],
299-
"size": 1077
334+
"size": 1363
300335
}
301336

302337
tsconfig.json::
303338
SemanticDiagnostics::
304339
Signatures::
305340

306341

307-
Diff:: !!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!
308-
--- nonIncremental.output.txt
309-
+++ incremental.output.txt
310-
@@ -1,12 +0,0 @@
311-
-a.ts:1:7 - error TS4094: Property 'p' of exported anonymous class type may not be private or protected.
312-
-
313-
-1 const a = class { private p = 10; };
314-
-   ~
315-
-
316-
- a.ts:1:7 - Add a type annotation to the variable a.
317-
- 1 const a = class { private p = 10; };
318-
-    ~
319-
-
320-
-
321-
-Found 1 error in a.ts:1
322-
-
323-
324342
Edit [3]:: no change
325343

326344
tsgo -b -v --noEmit
@@ -342,7 +360,7 @@ Output::
342360
[HH:MM:SS AM] Projects in this build:
343361
* tsconfig.json
344362

345-
[[90mHH:MM:SS AM[0m] Project 'tsconfig.json' is out of date because buildinfo file 'tsconfig.tsbuildinfo' indicates that some of the changes were not emitted
363+
[[90mHH:MM:SS AM[0m] Project 'tsconfig.json' is out of date because buildinfo file 'tsconfig.tsbuildinfo' indicates that program needs to report errors.
346364

347365
[HH:MM:SS AM] Building project 'tsconfig.json'...
348366

0 commit comments

Comments
 (0)