Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions internal/execute/incremental/affectedfileshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,17 @@ func (h *affectedFilesHandler) getFilesAffectedBy(path tspath.Path) []*ast.Sourc
seenFileNamesMap := h.forEachFileReferencedBy(
file,
func(currentFile *ast.SourceFile, currentPath tspath.Path) (queueForFile bool, fastReturn bool) {
// If the current file is not nil and has a shape change, we need to queue it for processing
if currentFile != nil && h.updateShapeSignature(currentFile, false) {
return true, false
if currentFile != nil {
info, _ := h.program.snapshot.fileInfos.Load(currentPath)
if !currentFile.IsDeclarationFile && info.signature == info.version {
// This file has no previous declaration signature. Computing one may show
// that propagation can stop, but requires declaration emit; skip that
// refinement and conservatively continue to its importers.
return true, false
}
if h.updateShapeSignature(currentFile, false) {
return true, false
}
}
return false, false
},
Expand Down
32 changes: 32 additions & 0 deletions internal/execute/tsctests/tsc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,38 @@ func TestTscIncremental(t *testing.T) {
}
}
testCases := []*tscInput{
{
subScenario: "incremental signature propagation through reexports",
files: FileMap{
"/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(`
{
"compilerOptions": {
"incremental": true,
"noEmit": true,
"module": "esnext",
},
}`),
"/home/src/workspaces/project/hub.ts": `export const value = 1;`,
"/home/src/workspaces/project/reexport.ts": `export { value } from "./hub";`,
"/home/src/workspaces/project/importer.ts": stringtestutil.Dedent(`
import { value } from "./reexport";
console.log(value);`),
},
edits: []*tscEdit{
{
caption: "append ordinary comment",
edit: func(sys *TestSys) {
sys.appendFile("/home/src/workspaces/project/hub.ts", "\n// comment")
},
},
{
caption: "change exported value",
edit: func(sys *TestSys) {
sys.replaceFileText("/home/src/workspaces/project/hub.ts", "value = 1", "value = 'one'")
},
},
},
},
{
subScenario: "serializing error chain",
files: FileMap{
Expand Down
105 changes: 40 additions & 65 deletions testdata/baselines/reference/tsbuild/noEmit/changes-incremental.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Found 2 errors in the same file, starting at: MessageablePerson.ts:7
//// [/home/src/workspaces/project/MessageablePerson.js] *rewrite with same content*
//// [/home/src/workspaces/project/main.js] *rewrite with same content*
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified*
{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.es2025.full.d.ts","./MessageablePerson.ts","./main.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":"fc3bcee26e986c769691717bfbe49525-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;\nexport default MessageablePerson;","signature":"9bca542f83dba4822510bd12bc5e9db9-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;\nexport default MessageablePerson;\n\n(116,7): error4094: Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected_4094\nmessage\n\n(116,7): error9027: Add_a_type_annotation_to_the_variable_0_9027\nwrapper\n","impliedNodeFormat":1},{"version":"f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"module":99},"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[[2,[{"pos":172,"end":184,"code":2304,"category":1,"messageKey":"Cannot_find_name_0_2304","messageArgs":["InstanceType"]},{"pos":185,"end":195,"code":2304,"category":1,"messageKey":"Cannot_find_name_0_2304","messageArgs":["ReturnType"]}]]]}
{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.es2025.full.d.ts","./MessageablePerson.ts","./main.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":"fc3bcee26e986c769691717bfbe49525-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;\nexport default MessageablePerson;","signature":"9bca542f83dba4822510bd12bc5e9db9-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;\nexport default MessageablePerson;\n\n(116,7): error4094: Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected_4094\nmessage\n\n(116,7): error9027: Add_a_type_annotation_to_the_variable_0_9027\nwrapper\n","impliedNodeFormat":1},"f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}"],"fileIdsList":[[2]],"options":{"module":99},"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[[2,[{"pos":172,"end":184,"code":2304,"category":1,"messageKey":"Cannot_find_name_0_2304","messageArgs":["InstanceType"]},{"pos":185,"end":195,"code":2304,"category":1,"messageKey":"Cannot_find_name_0_2304","messageArgs":["ReturnType"]}]]]}
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified*
{
"version": "FakeTSVersion",
Expand Down Expand Up @@ -302,13 +302,8 @@ Found 2 errors in the same file, starting at: MessageablePerson.ts:7
{
"fileName": "./main.ts",
"version": "f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}",
"signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n",
"impliedNodeFormat": "CommonJS",
"original": {
"version": "f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}",
"signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n",
"impliedNodeFormat": 1
}
"signature": "f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}",
"impliedNodeFormat": "CommonJS"
}
],
"fileIdsList": [
Expand Down Expand Up @@ -351,7 +346,7 @@ Found 2 errors in the same file, starting at: MessageablePerson.ts:7
]
]
],
"size": 2263
"size": 2169
}

tsconfig.json::
Expand All @@ -360,7 +355,6 @@ SemanticDiagnostics::
*refresh* /home/src/workspaces/project/main.ts
Signatures::
(computed .d.ts) /home/src/workspaces/project/MessageablePerson.ts
(computed .d.ts) /home/src/workspaces/project/main.ts


Edit [2]:: no change
Expand Down Expand Up @@ -417,7 +411,7 @@ Found 2 errors in the same file, starting at: MessageablePerson.ts:7
//// [/home/src/workspaces/project/MessageablePerson.js] *rewrite with same content*
//// [/home/src/workspaces/project/main.js] *rewrite with same content*
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo] *modified*
{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.es2025.full.d.ts","./MessageablePerson.ts","./main.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":"500cfddf7f97c595e46579b9b5afc9bd-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;\nexport default MessageablePerson;","signature":"3847cb0c7d8f5a6eaa57e0b19ab33ea8-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;\nexport default MessageablePerson;\n","impliedNodeFormat":1},{"version":"f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"abe7d9981d6018efb6b2b794f40a1607-export {};\n","impliedNodeFormat":1}],"fileIdsList":[[2]],"options":{"module":99},"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[[2,[{"pos":169,"end":181,"code":2304,"category":1,"messageKey":"Cannot_find_name_0_2304","messageArgs":["InstanceType"]},{"pos":182,"end":192,"code":2304,"category":1,"messageKey":"Cannot_find_name_0_2304","messageArgs":["ReturnType"]}]]]}
{"version":"FakeTSVersion","root":[[2,3]],"fileNames":["lib.es2025.full.d.ts","./MessageablePerson.ts","./main.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":"500cfddf7f97c595e46579b9b5afc9bd-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;\nexport default MessageablePerson;","signature":"3847cb0c7d8f5a6eaa57e0b19ab33ea8-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType<ReturnType<typeof wrapper>>;\nexport default MessageablePerson;\n","impliedNodeFormat":1},"f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}"],"fileIdsList":[[2]],"options":{"module":99},"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[[2,[{"pos":169,"end":181,"code":2304,"category":1,"messageKey":"Cannot_find_name_0_2304","messageArgs":["InstanceType"]},{"pos":182,"end":192,"code":2304,"category":1,"messageKey":"Cannot_find_name_0_2304","messageArgs":["ReturnType"]}]]]}
//// [/home/src/workspaces/project/tsconfig.tsbuildinfo.readable.baseline.txt] *modified*
{
"version": "FakeTSVersion",
Expand Down Expand Up @@ -465,13 +459,8 @@ Found 2 errors in the same file, starting at: MessageablePerson.ts:7
{
"fileName": "./main.ts",
"version": "f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}",
"signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n",
"impliedNodeFormat": "CommonJS",
"original": {
"version": "f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}",
"signature": "abe7d9981d6018efb6b2b794f40a1607-export {};\n",
"impliedNodeFormat": 1
}
"signature": "f1d6119c9df9ff1b48604c0e5c5f624f-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}",
"impliedNodeFormat": "CommonJS"
}
],
"fileIdsList": [
Expand Down Expand Up @@ -514,7 +503,7 @@ Found 2 errors in the same file, starting at: MessageablePerson.ts:7
]
]
],
"size": 2070
"size": 1976
}

tsconfig.json::
Expand All @@ -523,7 +512,6 @@ SemanticDiagnostics::
*refresh* /home/src/workspaces/project/main.ts
Signatures::
(computed .d.ts) /home/src/workspaces/project/MessageablePerson.ts
(computed .d.ts) /home/src/workspaces/project/main.ts


Edit [4]:: no change
Expand Down
Loading