Skip to content

Commit 84b536f

Browse files
committed
Implement assumeChangesAffectShape which means any change to file can affect the dependencies
This avoids having to generate d.ts files for the sources
1 parent 187095e commit 84b536f

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

src/compiler/builderState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ namespace ts {
314314

315315
const prevSignature = info.signature;
316316
let latestSignature: string;
317-
if (sourceFile.isDeclarationFile) {
317+
if (sourceFile.isDeclarationFile || programOfThisState.getCompilerOptions().assumeChangesAffectShape) {
318318
latestSignature = sourceFile.version;
319319
if (exportedModulesMapCache && latestSignature !== prevSignature) {
320320
// All the references in this file are exported

tests/baselines/reference/tsc/incremental/initial-build/assumeChangesAffectShape.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@ exports.foo = foo;
6666
},
6767
"./extrafile.ts": {
6868
"version": "-13403012629-export const extra = 10;",
69-
"signature": "-4859189518-export declare const extra = 10;\r\n",
69+
"signature": "-13403012629-export const extra = 10;",
7070
"affectsGlobalScope": false
7171
},
7272
"./module.ts": {
7373
"version": "-8446458946-export function foo(): string { return \"hello\"; }",
74-
"signature": "-8035635627-export declare function foo(): string;\r\n",
74+
"signature": "-8446458946-export function foo(): string { return \"hello\"; }",
7575
"affectsGlobalScope": false
7676
},
7777
"./main.ts": {
7878
"version": "-7083766686-import { foo } from \"./module\";foo();",
79-
"signature": "-4882119183-export {};\r\n",
79+
"signature": "-7083766686-import { foo } from \"./module\";foo();",
8080
"affectsGlobalScope": false
8181
}
8282
},
@@ -91,7 +91,11 @@ exports.foo = foo;
9191
"./module.ts"
9292
]
9393
},
94-
"exportedModulesMap": {},
94+
"exportedModulesMap": {
95+
"./main.ts": [
96+
"./module.ts"
97+
]
98+
},
9599
"semanticDiagnosticsPerFile": [
96100
"../../lib/lib.d.ts",
97101
"./extrafile.ts",
@@ -116,6 +120,7 @@ Output::
116120
exitCode:: ExitStatus.Success
117121

118122

123+
//// [/src/project/main.js] file written with same contents
119124
//// [/src/project/module.js]
120125
"use strict";
121126
exports.__esModule = true;
@@ -135,17 +140,17 @@ exports.foo = foo;
135140
},
136141
"./extrafile.ts": {
137142
"version": "-13403012629-export const extra = 10;",
138-
"signature": "-4859189518-export declare const extra = 10;\r\n",
143+
"signature": "-13403012629-export const extra = 10;",
139144
"affectsGlobalScope": false
140145
},
141146
"./module.ts": {
142147
"version": "-4300970970-export function foo(): string { return \"hello world\"; }",
143-
"signature": "-8035635627-export declare function foo(): string;\r\n",
148+
"signature": "-4300970970-export function foo(): string { return \"hello world\"; }",
144149
"affectsGlobalScope": false
145150
},
146151
"./main.ts": {
147152
"version": "-7083766686-import { foo } from \"./module\";foo();",
148-
"signature": "-4882119183-export {};\r\n",
153+
"signature": "-7083766686-import { foo } from \"./module\";foo();",
149154
"affectsGlobalScope": false
150155
}
151156
},
@@ -160,7 +165,11 @@ exports.foo = foo;
160165
"./module.ts"
161166
]
162167
},
163-
"exportedModulesMap": {},
168+
"exportedModulesMap": {
169+
"./main.ts": [
170+
"./module.ts"
171+
]
172+
},
164173
"semanticDiagnosticsPerFile": [
165174
"../../lib/lib.d.ts",
166175
"./extrafile.ts",
@@ -206,17 +215,17 @@ exports.foo = foo;
206215
},
207216
"./extrafile.ts": {
208217
"version": "-13403012629-export const extra = 10;",
209-
"signature": "-4859189518-export declare const extra = 10;\r\n",
218+
"signature": "-13403012629-export const extra = 10;",
210219
"affectsGlobalScope": false
211220
},
212221
"./module.ts": {
213222
"version": "-1237933216-export const x = 10;export function foo(): string { return \"hello world\"; }",
214-
"signature": "1387636182-export declare const x = 10;\r\nexport declare function foo(): string;\r\n",
223+
"signature": "-1237933216-export const x = 10;export function foo(): string { return \"hello world\"; }",
215224
"affectsGlobalScope": false
216225
},
217226
"./main.ts": {
218227
"version": "-7083766686-import { foo } from \"./module\";foo();",
219-
"signature": "-4882119183-export {};\r\n",
228+
"signature": "-7083766686-import { foo } from \"./module\";foo();",
220229
"affectsGlobalScope": false
221230
}
222231
},
@@ -231,7 +240,11 @@ exports.foo = foo;
231240
"./module.ts"
232241
]
233242
},
234-
"exportedModulesMap": {},
243+
"exportedModulesMap": {
244+
"./main.ts": [
245+
"./module.ts"
246+
]
247+
},
235248
"semanticDiagnosticsPerFile": [
236249
"../../lib/lib.d.ts",
237250
"./extrafile.ts",

0 commit comments

Comments
 (0)