Skip to content

Commit fc35e0a

Browse files
committed
Add test for self referencing package
1 parent dfb1e40 commit fc35e0a

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed

src/testRunner/unittests/tscWatch/forceConsistentCasingInFileNames.ts

+32
Original file line numberDiff line numberDiff line change
@@ -294,5 +294,37 @@ a;b;
294294
}, { currentDirectory: "/Users/name/projects/web" }),
295295
changes: emptyArray,
296296
});
297+
298+
verifyTscWatch({
299+
scenario: "forceConsistentCasingInFileNames",
300+
subScenario: "self name package reference",
301+
commandLineArgs: ["-w", "--explainFiles"],
302+
sys: () => createWatchedSystem({
303+
"/Users/name/projects/web/package.json": JSON.stringify({
304+
name: "@this/package",
305+
type: "module",
306+
exports: {
307+
".": "./dist/index.js"
308+
}
309+
}),
310+
"/Users/name/projects/web/index.ts": Utils.dedent`
311+
import * as me from "@this/package";
312+
me.thing();
313+
export function thing(): void {}
314+
`,
315+
"/Users/name/projects/web/tsconfig.json": JSON.stringify({
316+
compilerOptions: {
317+
module: "nodenext",
318+
outDir: "./dist",
319+
declarationDir: "./types",
320+
composite: true,
321+
forceConsistentCasingInFileNames: true,
322+
traceResolution: true,
323+
}
324+
}),
325+
"/a/lib/lib.esnext.full.d.ts": libFile.content,
326+
}, { currentDirectory: "/Users/name/projects/web" }),
327+
changes: emptyArray,
328+
});
297329
});
298330
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
Input::
2+
//// [/Users/name/projects/web/package.json]
3+
{"name":"@this/package","type":"module","exports":{".":"./dist/index.js"}}
4+
5+
//// [/Users/name/projects/web/index.ts]
6+
import * as me from "@this/package";
7+
me.thing();
8+
export function thing(): void {}
9+
10+
11+
//// [/Users/name/projects/web/tsconfig.json]
12+
{"compilerOptions":{"module":"nodenext","outDir":"./dist","declarationDir":"./types","composite":true,"forceConsistentCasingInFileNames":true,"traceResolution":true}}
13+
14+
//// [/a/lib/lib.esnext.full.d.ts]
15+
/// <reference no-default-lib="true"/>
16+
interface Boolean {}
17+
interface Function {}
18+
interface CallableFunction {}
19+
interface NewableFunction {}
20+
interface IArguments {}
21+
interface Number { toExponential: any; }
22+
interface Object {}
23+
interface RegExp {}
24+
interface String { charAt: any; }
25+
interface Array<T> { length: number; [n: number]: T; }
26+
27+
28+
/a/lib/tsc.js -w --explainFiles
29+
Output::
30+
>> Screen clear
31+
[12:00:23 AM] Starting compilation in watch mode...
32+
33+
Found 'package.json' at '/users/name/projects/web/package.json'.
34+
'package.json' does not have a 'typesVersions' field.
35+
======== Resolving module '@this/package' from '/Users/name/projects/web/index.ts'. ========
36+
Module resolution kind is not specified, using 'NodeNext'.
37+
File '/users/name/projects/web/package.json' exists according to earlier cached lookups.
38+
File '/users/name/projects/web/index.ts' exist - use it as a name resolution result.
39+
Resolving real path for '/users/name/projects/web/index.ts', result '/Users/name/projects/web/index.ts'.
40+
======== Module name '@this/package' was successfully resolved to '/users/name/projects/web/index.ts'. ========
41+
File '/a/lib/package.json' does not exist.
42+
File '/a/package.json' does not exist.
43+
File '/package.json' does not exist.
44+
index.ts:1:21 - error TS1149: File name '/users/name/projects/web/index.ts' differs from already included file name '/Users/name/projects/web/index.ts' only in casing.
45+
The file is in the program because:
46+
Matched by default include pattern '**/*'
47+
Imported via "@this/package" from file '/Users/name/projects/web/index.ts'
48+
File is ECMAScript module because '/users/name/projects/web/package.json' has field "type" with value "module"
49+
50+
1 import * as me from "@this/package";
51+
   ~~~~~~~~~~~~~~~
52+
53+
../../../../a/lib/lib.esnext.full.d.ts
54+
Default library for target 'esnext'
55+
index.ts
56+
Matched by default include pattern '**/*'
57+
Imported via "@this/package" from file 'index.ts'
58+
File is ECMAScript module because 'package.json' has field "type" with value "module"
59+
[12:00:36 AM] Found 1 error. Watching for file changes.
60+
61+
62+
63+
Program root files: ["/Users/name/projects/web/index.ts"]
64+
Program options: {"module":199,"outDir":"/Users/name/projects/web/dist","declarationDir":"/Users/name/projects/web/types","composite":true,"forceConsistentCasingInFileNames":true,"traceResolution":true,"watch":true,"explainFiles":true,"configFilePath":"/Users/name/projects/web/tsconfig.json"}
65+
Program structureReused: Not
66+
Program files::
67+
/a/lib/lib.esnext.full.d.ts
68+
/Users/name/projects/web/index.ts
69+
70+
Semantic diagnostics in builder refreshed for::
71+
/a/lib/lib.esnext.full.d.ts
72+
/Users/name/projects/web/index.ts
73+
74+
Shape signatures in builder refreshed for::
75+
/a/lib/lib.esnext.full.d.ts (used version)
76+
/users/name/projects/web/index.ts (computed .d.ts during emit)
77+
78+
WatchedFiles::
79+
/users/name/projects/web/tsconfig.json:
80+
{"fileName":"/Users/name/projects/web/tsconfig.json","pollingInterval":250}
81+
/users/name/projects/web/index.ts:
82+
{"fileName":"/Users/name/projects/web/index.ts","pollingInterval":250}
83+
/a/lib/lib.esnext.full.d.ts:
84+
{"fileName":"/a/lib/lib.esnext.full.d.ts","pollingInterval":250}
85+
/users/name/projects/web/package.json:
86+
{"fileName":"/Users/name/projects/web/package.json","pollingInterval":250}
87+
/users/name/projects/web/node_modules/@types:
88+
{"fileName":"/Users/name/projects/web/node_modules/@types","pollingInterval":500}
89+
90+
FsWatches::
91+
92+
FsWatchesRecursive::
93+
/users/name/projects/web:
94+
{"directoryName":"/users/name/projects/web"}
95+
96+
exitCode:: ExitStatus.undefined
97+
98+
//// [/Users/name/projects/web/dist/index.js]
99+
import * as me from "@this/package";
100+
me.thing();
101+
export function thing() { }
102+
103+
104+
//// [/Users/name/projects/web/types/index.d.ts]
105+
export declare function thing(): void;
106+
107+
108+
//// [/Users/name/projects/web/dist/tsconfig.tsbuildinfo]
109+
{"program":{"fileNames":["../../../../../a/lib/lib.esnext.full.d.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":"14361483761-import * as me from \"@this/package\";\nme.thing();\nexport function thing(): void {}\n","signature":"-2724770439-export declare function thing(): void;\n","impliedFormat":99}],"options":{"composite":true,"declarationDir":"../types","module":199,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[2,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2],"latestChangedDtsFile":"../types/index.d.ts"},"version":"FakeTSVersion"}
110+
111+
//// [/Users/name/projects/web/dist/tsconfig.tsbuildinfo.readable.baseline.txt]
112+
{
113+
"program": {
114+
"fileNames": [
115+
"../../../../../a/lib/lib.esnext.full.d.ts",
116+
"../index.ts"
117+
],
118+
"fileNamesList": [
119+
[
120+
"../index.ts"
121+
]
122+
],
123+
"fileInfos": {
124+
"../../../../../a/lib/lib.esnext.full.d.ts": {
125+
"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; }",
126+
"signature": "-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; }",
127+
"affectsGlobalScope": true,
128+
"impliedFormat": "commonjs"
129+
},
130+
"../index.ts": {
131+
"version": "14361483761-import * as me from \"@this/package\";\nme.thing();\nexport function thing(): void {}\n",
132+
"signature": "-2724770439-export declare function thing(): void;\n",
133+
"impliedFormat": "esnext"
134+
}
135+
},
136+
"options": {
137+
"composite": true,
138+
"declarationDir": "../types",
139+
"module": 199,
140+
"outDir": "./"
141+
},
142+
"referencedMap": {
143+
"../index.ts": [
144+
"../index.ts"
145+
]
146+
},
147+
"exportedModulesMap": {},
148+
"semanticDiagnosticsPerFile": [
149+
"../../../../../a/lib/lib.esnext.full.d.ts",
150+
"../index.ts"
151+
],
152+
"latestChangedDtsFile": "../types/index.d.ts"
153+
},
154+
"version": "FakeTSVersion",
155+
"size": 974
156+
}
157+

0 commit comments

Comments
 (0)