Skip to content

Commit a92aaed

Browse files
committed
Fix the issue with not serializing impliedFormat when signature == version of the file
1 parent ad1cebc commit a92aaed

File tree

4 files changed

+41
-24
lines changed

4 files changed

+41
-24
lines changed

src/compiler/builder.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,13 +751,18 @@ namespace ts {
751751
const signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
752752
const actualSignature = signature ?? value.signature;
753753
return value.version === actualSignature ?
754-
value.affectsGlobalScope ?
755-
{ version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
754+
value.affectsGlobalScope || value.impliedFormat ?
755+
// If file version is same as signature, dont serialize signature
756+
{ version: value.version, signature: undefined, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
757+
// If file info only contains version and signature and both are same we can just write string
756758
value.version :
757-
actualSignature !== undefined ?
759+
actualSignature !== undefined ? // If signature is not same as version, encode signature in the fileInfo
758760
signature === undefined ?
761+
// If we havent computed signature, use fileInfo as is
759762
value :
763+
// Serialize fileInfo with new updated signature
760764
{ version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
765+
// Signature of the FileInfo is undefined, serialize it as false
761766
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
762767
});
763768

src/compiler/builderState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ namespace ts {
8181
export interface FileInfo {
8282
readonly version: string;
8383
signature: string | undefined;
84-
affectsGlobalScope: boolean | undefined;
84+
affectsGlobalScope: true | undefined;
8585
impliedFormat: number | undefined;
8686
}
8787

tests/baselines/reference/tsbuild/moduleSpecifiers/synthesized-module-specifiers-across-projects-resolve-correctly.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ LassieDog.getDogConfig = () => LASSIE_CONFIG;
191191

192192

193193
//// [/src/src-dogs/tsconfig.tsbuildinfo]
194-
{"program":{"fileNames":["../../lib/lib.es2020.full.d.ts","../src-types/dogconfig.d.ts","../src-types/index.d.ts","./dogconfig.ts","./dog.ts","./lassie/lassieconfig.ts","./lassie/lassiedog.ts","./index.ts"],"fileInfos":[{"version":"-7698705165-/// <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; }","affectsGlobalScope":true,"impliedFormat":1},"-2632060142-export interface DogConfig {\r\n name: string;\r\n}\r\n","-5608794531-export * from './dogconfig.js';\r\n","1966273863-import { DogConfig } from 'src-types';\n\nexport const DOG_CONFIG: DogConfig = {\n name: 'Default dog',\n};\n","6091345804-import { DogConfig } from 'src-types';\nimport { DOG_CONFIG } from './dogconfig.js';\n\nexport abstract class Dog {\n\n public static getCapabilities(): DogConfig {\n return DOG_CONFIG;\n }\n}\n","4440579024-import { DogConfig } from 'src-types';\n\nexport const LASSIE_CONFIG: DogConfig = { name: 'Lassie' };\n","-32303727812-import { Dog } from '../dog.js';\nimport { LASSIE_CONFIG } from './lassieconfig.js';\n\nexport class LassieDog extends Dog {\n protected static getDogConfig = () => LASSIE_CONFIG;\n}\n","-15974991320-export * from 'src-types';\nexport * from './lassie/lassiedog.js';\n"],"options":{"composite":true,"declaration":true,"module":100},"fileIdsList":[[3,4],[3],[3,7],[5,6],[2]],"referencedMap":[[5,1],[4,2],[8,3],[6,2],[7,4],[3,5]],"exportedModulesMap":[[5,1],[4,2],[8,3],[6,2],[7,4],[3,5]],"semanticDiagnosticsPerFile":[1,5,4,8,6,7,2,3]},"version":"FakeTSVersion"}
194+
{"program":{"fileNames":["../../lib/lib.es2020.full.d.ts","../src-types/dogconfig.d.ts","../src-types/index.d.ts","./dogconfig.ts","./dog.ts","./lassie/lassieconfig.ts","./lassie/lassiedog.ts","./index.ts"],"fileInfos":[{"version":"-7698705165-/// <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; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-2632060142-export interface DogConfig {\r\n name: string;\r\n}\r\n","impliedFormat":99},{"version":"-5608794531-export * from './dogconfig.js';\r\n","impliedFormat":99},{"version":"1966273863-import { DogConfig } from 'src-types';\n\nexport const DOG_CONFIG: DogConfig = {\n name: 'Default dog',\n};\n","impliedFormat":99},{"version":"6091345804-import { DogConfig } from 'src-types';\nimport { DOG_CONFIG } from './dogconfig.js';\n\nexport abstract class Dog {\n\n public static getCapabilities(): DogConfig {\n return DOG_CONFIG;\n }\n}\n","impliedFormat":99},{"version":"4440579024-import { DogConfig } from 'src-types';\n\nexport const LASSIE_CONFIG: DogConfig = { name: 'Lassie' };\n","impliedFormat":99},{"version":"-32303727812-import { Dog } from '../dog.js';\nimport { LASSIE_CONFIG } from './lassieconfig.js';\n\nexport class LassieDog extends Dog {\n protected static getDogConfig = () => LASSIE_CONFIG;\n}\n","impliedFormat":99},{"version":"-15974991320-export * from 'src-types';\nexport * from './lassie/lassiedog.js';\n","impliedFormat":99}],"options":{"composite":true,"declaration":true,"module":100},"fileIdsList":[[3,4],[3],[3,7],[5,6],[2]],"referencedMap":[[5,1],[4,2],[8,3],[6,2],[7,4],[3,5]],"exportedModulesMap":[[5,1],[4,2],[8,3],[6,2],[7,4],[3,5]],"semanticDiagnosticsPerFile":[1,5,4,8,6,7,2,3]},"version":"FakeTSVersion"}
195195

196196
//// [/src/src-dogs/tsconfig.tsbuildinfo.readable.baseline.txt]
197197
{
@@ -235,31 +235,38 @@ LassieDog.getDogConfig = () => LASSIE_CONFIG;
235235
},
236236
"../src-types/dogconfig.d.ts": {
237237
"version": "-2632060142-export interface DogConfig {\r\n name: string;\r\n}\r\n",
238-
"signature": "-2632060142-export interface DogConfig {\r\n name: string;\r\n}\r\n"
238+
"signature": "-2632060142-export interface DogConfig {\r\n name: string;\r\n}\r\n",
239+
"impliedFormat": 99
239240
},
240241
"../src-types/index.d.ts": {
241242
"version": "-5608794531-export * from './dogconfig.js';\r\n",
242-
"signature": "-5608794531-export * from './dogconfig.js';\r\n"
243+
"signature": "-5608794531-export * from './dogconfig.js';\r\n",
244+
"impliedFormat": 99
243245
},
244246
"./dogconfig.ts": {
245247
"version": "1966273863-import { DogConfig } from 'src-types';\n\nexport const DOG_CONFIG: DogConfig = {\n name: 'Default dog',\n};\n",
246-
"signature": "1966273863-import { DogConfig } from 'src-types';\n\nexport const DOG_CONFIG: DogConfig = {\n name: 'Default dog',\n};\n"
248+
"signature": "1966273863-import { DogConfig } from 'src-types';\n\nexport const DOG_CONFIG: DogConfig = {\n name: 'Default dog',\n};\n",
249+
"impliedFormat": 99
247250
},
248251
"./dog.ts": {
249252
"version": "6091345804-import { DogConfig } from 'src-types';\nimport { DOG_CONFIG } from './dogconfig.js';\n\nexport abstract class Dog {\n\n public static getCapabilities(): DogConfig {\n return DOG_CONFIG;\n }\n}\n",
250-
"signature": "6091345804-import { DogConfig } from 'src-types';\nimport { DOG_CONFIG } from './dogconfig.js';\n\nexport abstract class Dog {\n\n public static getCapabilities(): DogConfig {\n return DOG_CONFIG;\n }\n}\n"
253+
"signature": "6091345804-import { DogConfig } from 'src-types';\nimport { DOG_CONFIG } from './dogconfig.js';\n\nexport abstract class Dog {\n\n public static getCapabilities(): DogConfig {\n return DOG_CONFIG;\n }\n}\n",
254+
"impliedFormat": 99
251255
},
252256
"./lassie/lassieconfig.ts": {
253257
"version": "4440579024-import { DogConfig } from 'src-types';\n\nexport const LASSIE_CONFIG: DogConfig = { name: 'Lassie' };\n",
254-
"signature": "4440579024-import { DogConfig } from 'src-types';\n\nexport const LASSIE_CONFIG: DogConfig = { name: 'Lassie' };\n"
258+
"signature": "4440579024-import { DogConfig } from 'src-types';\n\nexport const LASSIE_CONFIG: DogConfig = { name: 'Lassie' };\n",
259+
"impliedFormat": 99
255260
},
256261
"./lassie/lassiedog.ts": {
257262
"version": "-32303727812-import { Dog } from '../dog.js';\nimport { LASSIE_CONFIG } from './lassieconfig.js';\n\nexport class LassieDog extends Dog {\n protected static getDogConfig = () => LASSIE_CONFIG;\n}\n",
258-
"signature": "-32303727812-import { Dog } from '../dog.js';\nimport { LASSIE_CONFIG } from './lassieconfig.js';\n\nexport class LassieDog extends Dog {\n protected static getDogConfig = () => LASSIE_CONFIG;\n}\n"
263+
"signature": "-32303727812-import { Dog } from '../dog.js';\nimport { LASSIE_CONFIG } from './lassieconfig.js';\n\nexport class LassieDog extends Dog {\n protected static getDogConfig = () => LASSIE_CONFIG;\n}\n",
264+
"impliedFormat": 99
259265
},
260266
"./index.ts": {
261267
"version": "-15974991320-export * from 'src-types';\nexport * from './lassie/lassiedog.js';\n",
262-
"signature": "-15974991320-export * from 'src-types';\nexport * from './lassie/lassiedog.js';\n"
268+
"signature": "-15974991320-export * from 'src-types';\nexport * from './lassie/lassiedog.js';\n",
269+
"impliedFormat": 99
263270
}
264271
},
265272
"options": {
@@ -325,7 +332,7 @@ LassieDog.getDogConfig = () => LASSIE_CONFIG;
325332
]
326333
},
327334
"version": "FakeTSVersion",
328-
"size": 1802
335+
"size": 2019
329336
}
330337

331338
//// [/src/src-types/dogconfig.d.ts]
@@ -347,7 +354,7 @@ export * from './dogconfig.js';
347354

348355

349356
//// [/src/src-types/tsconfig.tsbuildinfo]
350-
{"program":{"fileNames":["../../lib/lib.es2020.full.d.ts","./dogconfig.ts","./index.ts"],"fileInfos":[{"version":"-7698705165-/// <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; }","affectsGlobalScope":true,"impliedFormat":1},"-5575793279-export interface DogConfig {\n name: string;\n}","-6189272282-export * from './dogconfig.js';"],"options":{"composite":true,"declaration":true,"module":100},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
357+
{"program":{"fileNames":["../../lib/lib.es2020.full.d.ts","./dogconfig.ts","./index.ts"],"fileInfos":[{"version":"-7698705165-/// <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; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-5575793279-export interface DogConfig {\n name: string;\n}","impliedFormat":99},{"version":"-6189272282-export * from './dogconfig.js';","impliedFormat":99}],"options":{"composite":true,"declaration":true,"module":100},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
351358

352359
//// [/src/src-types/tsconfig.tsbuildinfo.readable.baseline.txt]
353360
{
@@ -371,11 +378,13 @@ export * from './dogconfig.js';
371378
},
372379
"./dogconfig.ts": {
373380
"version": "-5575793279-export interface DogConfig {\n name: string;\n}",
374-
"signature": "-5575793279-export interface DogConfig {\n name: string;\n}"
381+
"signature": "-5575793279-export interface DogConfig {\n name: string;\n}",
382+
"impliedFormat": 99
375383
},
376384
"./index.ts": {
377385
"version": "-6189272282-export * from './dogconfig.js';",
378-
"signature": "-6189272282-export * from './dogconfig.js';"
386+
"signature": "-6189272282-export * from './dogconfig.js';",
387+
"impliedFormat": 99
379388
}
380389
},
381390
"options": {
@@ -400,6 +409,6 @@ export * from './dogconfig.js';
400409
]
401410
},
402411
"version": "FakeTSVersion",
403-
"size": 829
412+
"size": 891
404413
}
405414

tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export type { TheNum } from './const.cjs';
198198

199199

200200
//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo]
201-
{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// <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; }","affectsGlobalScope":true,"impliedFormat":1},"-11202312776-export type TheNum = 42;","-9668872159-export type { TheNum } from './const.cjs';"],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
201+
{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// <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; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-11202312776-export type TheNum = 42;","impliedFormat":1},{"version":"-9668872159-export type { TheNum } from './const.cjs';","impliedFormat":99}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
202202

203203
//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt]
204204
{
@@ -222,11 +222,13 @@ export type { TheNum } from './const.cjs';
222222
},
223223
"../const.cts": {
224224
"version": "-11202312776-export type TheNum = 42;",
225-
"signature": "-11202312776-export type TheNum = 42;"
225+
"signature": "-11202312776-export type TheNum = 42;",
226+
"impliedFormat": 1
226227
},
227228
"../index.ts": {
228229
"version": "-9668872159-export type { TheNum } from './const.cjs';",
229-
"signature": "-9668872159-export type { TheNum } from './const.cjs';"
230+
"signature": "-9668872159-export type { TheNum } from './const.cjs';",
231+
"impliedFormat": 99
230232
}
231233
},
232234
"options": {
@@ -251,7 +253,7 @@ export type { TheNum } from './const.cjs';
251253
]
252254
},
253255
"version": "FakeTSVersion",
254-
"size": 826
256+
"size": 887
255257
}
256258

257259
//// [/user/username/projects/myproject/packages/pkg1/build/index.js]
@@ -699,7 +701,7 @@ exitCode:: ExitStatus.undefined
699701
//// [/user/username/projects/myproject/packages/pkg2/build/const.cjs] file changed its modified time
700702
//// [/user/username/projects/myproject/packages/pkg2/build/const.d.cts] file changed its modified time
701703
//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo]
702-
{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.cts"],"fileInfos":[{"version":"-7698705165-/// <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; }","affectsGlobalScope":true,"impliedFormat":1},"-11202312776-export type TheNum = 42;",{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n","impliedFormat":1}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
704+
{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.cts"],"fileInfos":[{"version":"-7698705165-/// <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; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-11202312776-export type TheNum = 42;","impliedFormat":1},{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n","impliedFormat":1}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
703705

704706
//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt]
705707
{
@@ -723,7 +725,8 @@ exitCode:: ExitStatus.undefined
723725
},
724726
"../const.cts": {
725727
"version": "-11202312776-export type TheNum = 42;",
726-
"signature": "-11202312776-export type TheNum = 42;"
728+
"signature": "-11202312776-export type TheNum = 42;",
729+
"impliedFormat": 1
727730
},
728731
"../index.cts": {
729732
"version": "-9668872159-export type { TheNum } from './const.cjs';",
@@ -753,7 +756,7 @@ exitCode:: ExitStatus.undefined
753756
]
754757
},
755758
"version": "FakeTSVersion",
756-
"size": 928
759+
"size": 958
757760
}
758761

759762
//// [/user/username/projects/myproject/packages/pkg2/build/index.cjs]

0 commit comments

Comments
 (0)