Skip to content

Commit 7ef9a15

Browse files
committed
Revert duplicate file check when writing buildInfo
1 parent 6742e55 commit 7ef9a15

File tree

3 files changed

+245
-9
lines changed

3 files changed

+245
-9
lines changed

internal/execute/incremental/snapshottobuildinfo.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (t *toBuildInfo) collectRootFiles() {
197197
}
198198

199199
func (t *toBuildInfo) setFileInfoAndEmitSignatures() {
200-
t.buildInfo.FileInfos = core.MapNonNil(t.program.GetSourceFiles(), func(file *ast.SourceFile) *BuildInfoFileInfo {
200+
t.buildInfo.FileInfos = core.Map(t.program.GetSourceFiles(), func(file *ast.SourceFile) *BuildInfoFileInfo {
201201
info, _ := t.snapshot.fileInfos.Load(file.Path())
202202
fileId := t.toFileId(file.Path())
203203
// tryAddRoot(key, fileId);
@@ -206,11 +206,6 @@ func (t *toBuildInfo) setFileInfoAndEmitSignatures() {
206206
panic(fmt.Sprintf("File name at index %d does not match expected relative path or libName: %s != %s", fileId-1, t.buildInfo.FileNames[fileId-1], t.relativeToBuildInfo(string(file.Path()))))
207207
}
208208
}
209-
if int(fileId) != len(t.buildInfo.FileNames) {
210-
// Duplicate - for now ignore
211-
return nil
212-
}
213-
214209
if t.snapshot.options.Composite.IsTrue() {
215210
if !ast.IsJsonSourceFile(file) && t.program.SourceFileMayBeEmitted(file, false) {
216211
if emitSignature, loaded := t.snapshot.emitSignatures.Load(file.Path()); !loaded {
@@ -235,9 +230,6 @@ func (t *toBuildInfo) setFileInfoAndEmitSignatures() {
235230
}
236231
return newBuildInfoFileInfo(info)
237232
})
238-
if t.buildInfo.FileInfos == nil {
239-
t.buildInfo.FileInfos = []*BuildInfoFileInfo{}
240-
}
241233
}
242234

243235
func (t *toBuildInfo) setRootOfIncrementalProgram() {

internal/execute/tsctests/tsc_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,54 @@ func TestTscIncremental(t *testing.T) {
18321832
},
18331833
},
18341834
},
1835+
{
1836+
subScenario: "Compile incremental with case insensitive file names",
1837+
commandLineArgs: []string{"-p", "."},
1838+
files: FileMap{
1839+
"/home/project/tsconfig.json": stringtestutil.Dedent(`
1840+
{
1841+
"compilerOptions": {
1842+
"incremental": true
1843+
},
1844+
}`),
1845+
"/home/project/src/index.ts": stringtestutil.Dedent(`
1846+
import type { Foo1 } from 'lib1';
1847+
import type { Foo2 } from 'lib2';
1848+
export const foo1: Foo1 = { foo: "a" };
1849+
export const foo2: Foo2 = { foo: "b" };`),
1850+
"/home/node_modules/lib1/index.d.ts": stringtestutil.Dedent(`
1851+
import type { Foo } from 'someLib';
1852+
export type { Foo as Foo1 };`),
1853+
"/home/node_modules/lib1/package.json": stringtestutil.Dedent(`
1854+
{
1855+
"name": "lib1"
1856+
}`),
1857+
"/home/node_modules/lib2/index.d.ts": stringtestutil.Dedent(`
1858+
import type { Foo } from 'somelib';
1859+
export type { Foo as Foo2 };
1860+
export declare const foo2: Foo;`),
1861+
"/home/node_modules/lib2/package.json": stringtestutil.Dedent(`
1862+
{
1863+
"name": "lib2"
1864+
}
1865+
`),
1866+
"/home/node_modules/someLib/index.d.ts": stringtestutil.Dedent(`
1867+
import type { Str } from 'otherLib';
1868+
export type Foo = { foo: Str; };`),
1869+
"/home/node_modules/someLib/package.json": stringtestutil.Dedent(`
1870+
{
1871+
"name": "somelib"
1872+
}`),
1873+
"/home/node_modules/otherLib/index.d.ts": stringtestutil.Dedent(`
1874+
export type Str = string;`),
1875+
"/home/node_modules/otherLib/package.json": stringtestutil.Dedent(`
1876+
{
1877+
"name": "otherlib"
1878+
}`),
1879+
},
1880+
cwd: "/home/project",
1881+
ignoreCase: true,
1882+
},
18351883
}
18361884

18371885
for _, test := range testCases {
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
currentDirectory::/home/project
2+
useCaseSensitiveFileNames::false
3+
Input::
4+
//// [/home/node_modules/lib1/index.d.ts] *new*
5+
import type { Foo } from 'someLib';
6+
export type { Foo as Foo1 };
7+
//// [/home/node_modules/lib1/package.json] *new*
8+
{
9+
"name": "lib1"
10+
}
11+
//// [/home/node_modules/lib2/index.d.ts] *new*
12+
import type { Foo } from 'somelib';
13+
export type { Foo as Foo2 };
14+
export declare const foo2: Foo;
15+
//// [/home/node_modules/lib2/package.json] *new*
16+
{
17+
"name": "lib2"
18+
}
19+
//// [/home/node_modules/otherLib/index.d.ts] *new*
20+
export type Str = string;
21+
//// [/home/node_modules/otherLib/package.json] *new*
22+
{
23+
"name": "otherlib"
24+
}
25+
//// [/home/node_modules/someLib/index.d.ts] *new*
26+
import type { Str } from 'otherLib';
27+
export type Foo = { foo: Str; };
28+
//// [/home/node_modules/someLib/package.json] *new*
29+
{
30+
"name": "somelib"
31+
}
32+
//// [/home/project/src/index.ts] *new*
33+
import type { Foo1 } from 'lib1';
34+
import type { Foo2 } from 'lib2';
35+
export const foo1: Foo1 = { foo: "a" };
36+
export const foo2: Foo2 = { foo: "b" };
37+
//// [/home/project/tsconfig.json] *new*
38+
{
39+
"compilerOptions": {
40+
"incremental": true
41+
},
42+
}
43+
44+
tsgo -p .
45+
ExitStatus:: DiagnosticsPresent_OutputsGenerated
46+
Output::
47+
../node_modules/lib2/index.d.ts:1:26 - error TS1149: File name '/home/node_modules/somelib/index.d.ts' differs from already included file name '/home/node_modules/someLib/index.d.ts' only in casing.
48+
The file is in the program because:
49+
Imported via 'someLib' from file '/home/node_modules/lib1/index.d.ts'
50+
Imported via 'somelib' from file '/home/node_modules/lib2/index.d.ts'
51+
52+
1 import type { Foo } from 'somelib';
53+
   ~~~~~~~~~
54+
55+
../node_modules/lib1/index.d.ts:1:26 - File is included via import here.
56+
1 import type { Foo } from 'someLib';
57+
   ~~~~~~~~~
58+
59+
60+
Found 1 error in ../node_modules/lib2/index.d.ts:1
61+
62+
//// [/home/project/src/index.js] *new*
63+
"use strict";
64+
Object.defineProperty(exports, "__esModule", { value: true });
65+
exports.foo2 = exports.foo1 = void 0;
66+
exports.foo1 = { foo: "a" };
67+
exports.foo2 = { foo: "b" };
68+
69+
//// [/home/project/tsconfig.tsbuildinfo] *new*
70+
{"version":"FakeTSVersion","errors":true,"root":[6],"fileNames":["lib.d.ts","../node_modules/otherlib/index.d.ts","../node_modules/somelib/index.d.ts","../node_modules/lib1/index.d.ts","../node_modules/lib2/index.d.ts","./src/index.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},"1fe659ed0634bb57b6dc25e9062f1162-export type Str = string;","12e112ff6e2744bb42d8e0b511e44117-import type { Str } from 'otherLib';\nexport type Foo = { foo: Str; };","b6305455d920a6729c435e6acf45eff6-import type { Foo } from 'someLib';\nexport type { Foo as Foo1 };","a5393e550a9c20a242a120bf6410db48-import type { Foo } from 'somelib';\nexport type { Foo as Foo2 };\nexport declare const foo2: Foo;","42aef197ff5f079223e2c29fb2e77cc5-import type { Foo1 } from 'lib1';\nimport type { Foo2 } from 'lib2';\nexport const foo1: Foo1 = { foo: \"a\" };\nexport const foo2: Foo2 = { foo: \"b\" };"],"fileIdsList":[[3],[2],[4,5]],"referencedMap":[[4,1],[5,1],[3,2],[6,3]]}
71+
//// [/home/project/tsconfig.tsbuildinfo.readable.baseline.txt] *new*
72+
{
73+
"version": "FakeTSVersion",
74+
"errors": true,
75+
"root": [
76+
{
77+
"files": [
78+
"./src/index.ts"
79+
],
80+
"original": 6
81+
}
82+
],
83+
"fileNames": [
84+
"lib.d.ts",
85+
"../node_modules/otherlib/index.d.ts",
86+
"../node_modules/somelib/index.d.ts",
87+
"../node_modules/lib1/index.d.ts",
88+
"../node_modules/lib2/index.d.ts",
89+
"./src/index.ts"
90+
],
91+
"fileInfos": [
92+
{
93+
"fileName": "lib.d.ts",
94+
"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; };",
95+
"signature": "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; };",
96+
"affectsGlobalScope": true,
97+
"impliedNodeFormat": "CommonJS",
98+
"original": {
99+
"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; };",
100+
"affectsGlobalScope": true,
101+
"impliedNodeFormat": 1
102+
}
103+
},
104+
{
105+
"fileName": "../node_modules/otherlib/index.d.ts",
106+
"version": "1fe659ed0634bb57b6dc25e9062f1162-export type Str = string;",
107+
"signature": "1fe659ed0634bb57b6dc25e9062f1162-export type Str = string;",
108+
"impliedNodeFormat": "CommonJS"
109+
},
110+
{
111+
"fileName": "../node_modules/somelib/index.d.ts",
112+
"version": "12e112ff6e2744bb42d8e0b511e44117-import type { Str } from 'otherLib';\nexport type Foo = { foo: Str; };",
113+
"signature": "12e112ff6e2744bb42d8e0b511e44117-import type { Str } from 'otherLib';\nexport type Foo = { foo: Str; };",
114+
"impliedNodeFormat": "CommonJS"
115+
},
116+
{
117+
"fileName": "../node_modules/lib1/index.d.ts",
118+
"version": "b6305455d920a6729c435e6acf45eff6-import type { Foo } from 'someLib';\nexport type { Foo as Foo1 };",
119+
"signature": "b6305455d920a6729c435e6acf45eff6-import type { Foo } from 'someLib';\nexport type { Foo as Foo1 };",
120+
"impliedNodeFormat": "CommonJS"
121+
},
122+
{
123+
"fileName": "../node_modules/lib2/index.d.ts",
124+
"version": "a5393e550a9c20a242a120bf6410db48-import type { Foo } from 'somelib';\nexport type { Foo as Foo2 };\nexport declare const foo2: Foo;",
125+
"signature": "a5393e550a9c20a242a120bf6410db48-import type { Foo } from 'somelib';\nexport type { Foo as Foo2 };\nexport declare const foo2: Foo;",
126+
"impliedNodeFormat": "CommonJS"
127+
},
128+
{
129+
"fileName": "./src/index.ts",
130+
"version": "42aef197ff5f079223e2c29fb2e77cc5-import type { Foo1 } from 'lib1';\nimport type { Foo2 } from 'lib2';\nexport const foo1: Foo1 = { foo: \"a\" };\nexport const foo2: Foo2 = { foo: \"b\" };",
131+
"signature": "42aef197ff5f079223e2c29fb2e77cc5-import type { Foo1 } from 'lib1';\nimport type { Foo2 } from 'lib2';\nexport const foo1: Foo1 = { foo: \"a\" };\nexport const foo2: Foo2 = { foo: \"b\" };",
132+
"impliedNodeFormat": "CommonJS"
133+
}
134+
],
135+
"fileIdsList": [
136+
[
137+
"../node_modules/somelib/index.d.ts"
138+
],
139+
[
140+
"../node_modules/otherlib/index.d.ts"
141+
],
142+
[
143+
"../node_modules/lib1/index.d.ts",
144+
"../node_modules/lib2/index.d.ts"
145+
]
146+
],
147+
"referencedMap": {
148+
"../node_modules/lib1/index.d.ts": [
149+
"../node_modules/somelib/index.d.ts"
150+
],
151+
"../node_modules/lib2/index.d.ts": [
152+
"../node_modules/somelib/index.d.ts"
153+
],
154+
"../node_modules/somelib/index.d.ts": [
155+
"../node_modules/otherlib/index.d.ts"
156+
],
157+
"./src/index.ts": [
158+
"../node_modules/lib1/index.d.ts",
159+
"../node_modules/lib2/index.d.ts"
160+
]
161+
},
162+
"size": 1685
163+
}
164+
//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib*
165+
/// <reference no-default-lib="true"/>
166+
interface Boolean {}
167+
interface Function {}
168+
interface CallableFunction {}
169+
interface NewableFunction {}
170+
interface IArguments {}
171+
interface Number { toExponential: any; }
172+
interface Object {}
173+
interface RegExp {}
174+
interface String { charAt: any; }
175+
interface Array<T> { length: number; [n: number]: T; }
176+
interface ReadonlyArray<T> {}
177+
interface SymbolConstructor {
178+
(desc?: string | number): symbol;
179+
for(name: string): symbol;
180+
readonly toStringTag: symbol;
181+
}
182+
declare var Symbol: SymbolConstructor;
183+
interface Symbol {
184+
readonly [Symbol.toStringTag]: string;
185+
}
186+
declare const console: { log(msg: any): void; };
187+
188+
tsconfig.json::
189+
SemanticDiagnostics::
190+
*refresh* /home/src/tslibs/TS/Lib/lib.d.ts
191+
*refresh* /home/node_modules/otherLib/index.d.ts
192+
*refresh* /home/node_modules/someLib/index.d.ts
193+
*refresh* /home/node_modules/lib1/index.d.ts
194+
*refresh* /home/node_modules/lib2/index.d.ts
195+
*refresh* /home/project/src/index.ts
196+
Signatures::

0 commit comments

Comments
 (0)