Skip to content

Commit 2bd4c2d

Browse files
Exclude output-write diagnostics from declaration signatures
1 parent 763c65d commit 2bd4c2d

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎tsc/internal/execute/incremental/snapshot.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ func (s *snapshot) computeSignatureWithDiagnostics(file *ast.SourceFile, text st
400400
var builder strings.Builder
401401
builder.WriteString(getTextHandlingSourceMapForSignature(text, data))
402402
for _, diag := range data.Diagnostics {
403+
// A failed output write is not a diagnostic of the declaration's contents.
404+
// Including it would change the signature once a later attempt writes
405+
// successfully, marking unchanged declarations as changed.
406+
if diag.Code() == diagnostics.Could_not_write_file_0_Colon_1.Code() {
407+
continue
408+
}
403409
diagnosticToStringBuilder(diag, file, &builder)
404410
}
405411
return s.computeHash(builder.String())

‎tsc/testdata/baselines/reference/tsc/incremental/declaration-emit-reports-failed-write-without-panicking.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ declare const console: { log(msg: any): void; };
4040
export declare const a = 1;
4141

4242
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *new*
43-
{"version":"FakeTSVersion","root":[2],"fileNames":["lib.es2026.full.d.ts","./src/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":"f5c8fff6e1fca35f4a292d48868d4086-export const a = 1;","signature":"3c0d6bd71647a06c9b7bfd6cbfdfc05b-export declare const a = 1;\n\nerror5033: Could_not_write_file_0_Colon_1_5033\n/home/src/workspaces/project/dist/a.js\nwrite \"home/src/workspaces/project/dist/a.js\": path exists but is not a regular file\n","impliedNodeFormat":1}],"options":{"declaration":true,"outDir":"./dist","rootDir":"./src"},"emitDiagnosticsPerFile":[[2,[{"noFile":true,"pos":-1,"end":-1,"code":5033,"category":1,"messageKey":"Could_not_write_file_0_Colon_1_5033","messageArgs":["/home/src/workspaces/project/dist/a.js","write \"home/src/workspaces/project/dist/a.js\": path exists but is not a regular file"]}]]]}
43+
{"version":"FakeTSVersion","root":[2],"fileNames":["lib.es2026.full.d.ts","./src/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":"f5c8fff6e1fca35f4a292d48868d4086-export const a = 1;","signature":"67cd7ccc14045107336f34154f76a8ca-export declare const a = 1;\n","impliedNodeFormat":1}],"options":{"declaration":true,"outDir":"./dist","rootDir":"./src"},"emitDiagnosticsPerFile":[[2,[{"noFile":true,"pos":-1,"end":-1,"code":5033,"category":1,"messageKey":"Could_not_write_file_0_Colon_1_5033","messageArgs":["/home/src/workspaces/project/dist/a.js","write \"home/src/workspaces/project/dist/a.js\": path exists but is not a regular file"]}]]]}
4444
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new*
4545
{
4646
"version": "FakeTSVersion",
@@ -72,11 +72,11 @@ export declare const a = 1;
7272
{
7373
"fileName": "./src/a.ts",
7474
"version": "f5c8fff6e1fca35f4a292d48868d4086-export const a = 1;",
75-
"signature": "3c0d6bd71647a06c9b7bfd6cbfdfc05b-export declare const a = 1;\n\nerror5033: Could_not_write_file_0_Colon_1_5033\n/home/src/workspaces/project/dist/a.js\nwrite \"home/src/workspaces/project/dist/a.js\": path exists but is not a regular file\n",
75+
"signature": "67cd7ccc14045107336f34154f76a8ca-export declare const a = 1;\n",
7676
"impliedNodeFormat": "CommonJS",
7777
"original": {
7878
"version": "f5c8fff6e1fca35f4a292d48868d4086-export const a = 1;",
79-
"signature": "3c0d6bd71647a06c9b7bfd6cbfdfc05b-export declare const a = 1;\n\nerror5033: Could_not_write_file_0_Colon_1_5033\n/home/src/workspaces/project/dist/a.js\nwrite \"home/src/workspaces/project/dist/a.js\": path exists but is not a regular file\n",
79+
"signature": "67cd7ccc14045107336f34154f76a8ca-export declare const a = 1;\n",
8080
"impliedNodeFormat": 1
8181
}
8282
}
@@ -105,7 +105,7 @@ export declare const a = 1;
105105
]
106106
]
107107
],
108-
"size": 1572
108+
"size": 1394
109109
}
110110

111111
tsconfig.json::

0 commit comments

Comments
 (0)