Skip to content

Commit dd1cef2

Browse files
committed
Whenver we cant use state delay signature calculation and use source file version as signature
1 parent 925e70e commit dd1cef2

File tree

196 files changed

+3079
-2361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+3079
-2361
lines changed

src/compiler/builderState.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ namespace ts {
4545
* Otherwise undefined
4646
*/
4747
readonly exportedModulesMap: ESMap<Path, BuilderState.ReferencedSet> | undefined;
48+
49+
/**
50+
* true if file version is used as signature
51+
* This helps in delaying the calculation of the d.ts hash as version for the file till reasonable time
52+
*/
53+
useFileVersionAsSignature: boolean;
4854
/**
4955
* Map of files that have already called update signature.
5056
* That means hence forth these files are assumed to have
@@ -236,7 +242,8 @@ namespace ts {
236242
fileInfos,
237243
referencedMap,
238244
exportedModulesMap,
239-
hasCalledUpdateShapeSignature
245+
hasCalledUpdateShapeSignature,
246+
useFileVersionAsSignature: !useOldState
240247
};
241248
}
242249

@@ -258,6 +265,7 @@ namespace ts {
258265
referencedMap: state.referencedMap && new Map(state.referencedMap),
259266
exportedModulesMap: state.exportedModulesMap && new Map(state.exportedModulesMap),
260267
hasCalledUpdateShapeSignature: new Set(state.hasCalledUpdateShapeSignature),
268+
useFileVersionAsSignature: state.useFileVersionAsSignature,
261269
};
262270
}
263271

@@ -317,7 +325,7 @@ namespace ts {
317325

318326
const prevSignature = info.signature;
319327
let latestSignature: string | undefined;
320-
if (!sourceFile.isDeclarationFile) {
328+
if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) {
321329
const emitOutput = getFileEmitOutput(
322330
programOfThisState,
323331
sourceFile,

src/testRunner/unittests/tscWatch/incremental.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ namespace ts.tscWatch {
164164
});
165165
assert.deepEqual(state.fileInfos.get(file1.path as Path), {
166166
version: system.createHash(file1.content),
167-
signature: system.createHash(`${file1.content.replace("export ", "export declare ")}\n`),
167+
signature: system.createHash(file1.content),
168168
affectsGlobalScope: false,
169169
});
170170
assert.deepEqual(state.fileInfos.get(file2.path as Path), {
171171
version: system.createHash(fileModified.content),
172-
signature: system.createHash("export declare const y: string;\n"),
172+
signature: system.createHash(fileModified.content),
173173
affectsGlobalScope: false,
174174
});
175175

src/testRunner/unittests/tsserver/compileOnSave.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ function bar() {
951951
}
952952

953953
// Change file1 get affected file list
954-
verifyLocalEdit(file1, "hello", "world");
954+
verifyLocalEdit(file1, "hello", "world", /*returnsAllFilesAsAffected*/ !declaration); // Signatures are not initialized before this request
955955
verifyLocalEdit(file1, "world", "hello");
956956
verifyLocalEdit(file1, "hello", "world");
957957

tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-changes/builds-after-fixing-config-file-errors.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports.bar = bar;
3434

3535

3636
//// [/src/tsconfig.tsbuildinfo]
37-
{"program":{"fileNames":["../lib/lib.d.ts","./a.ts","./b.ts"],"fileInfos":[{"version":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"4646078106-export function foo() { }","signature":"-6972466928-export declare function foo(): void;\r\n","affectsGlobalScope":false},{"version":"1045484683-export function bar() { }","signature":"-1357953631-export declare function bar(): void;\r\n","affectsGlobalScope":false}],"options":{"composite":true,"declaration":true,"configFilePath":"./tsconfig.json"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
37+
{"program":{"fileNames":["../lib/lib.d.ts","./a.ts","./b.ts"],"fileInfos":[{"version":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"4646078106-export function foo() { }","signature":"4646078106-export function foo() { }","affectsGlobalScope":false},{"version":"1045484683-export function bar() { }","signature":"1045484683-export function bar() { }","affectsGlobalScope":false}],"options":{"composite":true,"declaration":true,"configFilePath":"./tsconfig.json"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
3838

3939
//// [/src/tsconfig.tsbuildinfo.readable.baseline.txt]
4040
{
@@ -52,12 +52,12 @@ exports.bar = bar;
5252
},
5353
"./a.ts": {
5454
"version": "4646078106-export function foo() { }",
55-
"signature": "-6972466928-export declare function foo(): void;\r\n",
55+
"signature": "4646078106-export function foo() { }",
5656
"affectsGlobalScope": false
5757
},
5858
"./b.ts": {
5959
"version": "1045484683-export function bar() { }",
60-
"signature": "-1357953631-export declare function bar(): void;\r\n",
60+
"signature": "1045484683-export function bar() { }",
6161
"affectsGlobalScope": false
6262
}
6363
},
@@ -75,6 +75,6 @@ exports.bar = bar;
7575
]
7676
},
7777
"version": "FakeTSVersion",
78-
"size": 1488
78+
"size": 1456
7979
}
8080

tests/baselines/reference/tsbuild/configFileExtends/initial-build/when-building-project-uses-reference-and-both-extend-config-with-include.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ exports.a = 1;
7272

7373

7474
//// [/src/target-tsc-build/shared/tsconfig.tsbuildinfo]
75-
{"program":{"fileNames":["../../../lib/lib.d.ts","../../shared/index.ts","../../shared/typings-base/globals.d.ts"],"fileInfos":[{"version":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-22125360210-export const a: Unrestricted = 1;","signature":"-478734393-export declare const a: Unrestricted;\r\n","affectsGlobalScope":false},{"version":"4725476611-type Unrestricted = any;","signature":"4725476611-type Unrestricted = any;","affectsGlobalScope":true}],"options":{"composite":true,"outDir":"..","rootDir":"../..","listFiles":true,"configFilePath":"../../shared/tsconfig.json"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
75+
{"program":{"fileNames":["../../../lib/lib.d.ts","../../shared/index.ts","../../shared/typings-base/globals.d.ts"],"fileInfos":[{"version":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-22125360210-export const a: Unrestricted = 1;","signature":"-22125360210-export const a: Unrestricted = 1;","affectsGlobalScope":false},{"version":"4725476611-type Unrestricted = any;","signature":"4725476611-type Unrestricted = any;","affectsGlobalScope":true}],"options":{"composite":true,"outDir":"..","rootDir":"../..","listFiles":true,"configFilePath":"../../shared/tsconfig.json"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
7676

7777
//// [/src/target-tsc-build/shared/tsconfig.tsbuildinfo.readable.baseline.txt]
7878
{
@@ -90,7 +90,7 @@ exports.a = 1;
9090
},
9191
"../../shared/index.ts": {
9292
"version": "-22125360210-export const a: Unrestricted = 1;",
93-
"signature": "-478734393-export declare const a: Unrestricted;\r\n",
93+
"signature": "-22125360210-export const a: Unrestricted = 1;",
9494
"affectsGlobalScope": false
9595
},
9696
"../../shared/typings-base/globals.d.ts": {
@@ -115,7 +115,7 @@ exports.a = 1;
115115
]
116116
},
117117
"version": "FakeTSVersion",
118-
"size": 1573
118+
"size": 1567
119119
}
120120

121121
//// [/src/target-tsc-build/webpack/index.d.ts]
@@ -130,7 +130,7 @@ exports.b = 1;
130130

131131

132132
//// [/src/target-tsc-build/webpack/tsconfig.tsbuildinfo]
133-
{"program":{"fileNames":["../../../lib/lib.d.ts","../../webpack/index.ts","../../shared/typings-base/globals.d.ts"],"fileInfos":[{"version":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-14405273073-export const b: Unrestricted = 1;","signature":"-5074241048-export declare const b: Unrestricted;\r\n","affectsGlobalScope":false},{"version":"4725476611-type Unrestricted = any;","signature":"4725476611-type Unrestricted = any;","affectsGlobalScope":true}],"options":{"composite":true,"outDir":"..","rootDir":"../..","listFiles":true,"configFilePath":"../../webpack/tsconfig.json"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,2]},"version":"FakeTSVersion"}
133+
{"program":{"fileNames":["../../../lib/lib.d.ts","../../webpack/index.ts","../../shared/typings-base/globals.d.ts"],"fileInfos":[{"version":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <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> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-14405273073-export const b: Unrestricted = 1;","signature":"-14405273073-export const b: Unrestricted = 1;","affectsGlobalScope":false},{"version":"4725476611-type Unrestricted = any;","signature":"4725476611-type Unrestricted = any;","affectsGlobalScope":true}],"options":{"composite":true,"outDir":"..","rootDir":"../..","listFiles":true,"configFilePath":"../../webpack/tsconfig.json"},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,2]},"version":"FakeTSVersion"}
134134

135135
//// [/src/target-tsc-build/webpack/tsconfig.tsbuildinfo.readable.baseline.txt]
136136
{
@@ -148,7 +148,7 @@ exports.b = 1;
148148
},
149149
"../../webpack/index.ts": {
150150
"version": "-14405273073-export const b: Unrestricted = 1;",
151-
"signature": "-5074241048-export declare const b: Unrestricted;\r\n",
151+
"signature": "-14405273073-export const b: Unrestricted = 1;",
152152
"affectsGlobalScope": false
153153
},
154154
"../../shared/typings-base/globals.d.ts": {
@@ -173,6 +173,6 @@ exports.b = 1;
173173
]
174174
},
175175
"version": "FakeTSVersion",
176-
"size": 1576
176+
"size": 1569
177177
}
178178

0 commit comments

Comments
 (0)