Skip to content

Commit 06b18b3

Browse files
committed
More tests
1 parent d09ac1f commit 06b18b3

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed

internal/execute/tsctests/tsc_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,27 @@ func TestForceConsistentCasingInFileNames(t *testing.T) {
10411041
commandLineArgs: []string{"-p", "/user/username/projects/myproject", "--explainFiles", "--traceResolution"},
10421042
ignoreCase: true,
10431043
},
1044+
{
1045+
subScenario: "with triple slash ref from file",
1046+
files: FileMap{
1047+
"/home/src/workspaces/project/src/c.ts": `/// <reference path="./D.ts"/>`,
1048+
"/home/src/workspaces/project/src/d.ts": `declare class c { }`,
1049+
"/home/src/workspaces/project/tsconfig.json": "{ }",
1050+
},
1051+
ignoreCase: true,
1052+
},
1053+
{
1054+
subScenario: "two files exist on disk that differs only in casing",
1055+
files: FileMap{
1056+
"/home/src/workspaces/project/c.ts": `import {x} from "./D"`,
1057+
"/home/src/workspaces/project/D.ts": `export const x = 10;`,
1058+
"/home/src/workspaces/project/d.ts": `export const y = 20;`,
1059+
"/home/src/workspaces/project/tsconfig.json": stringtestutil.Dedent(`
1060+
{
1061+
"files": ["c.ts", "d.ts"]
1062+
}`),
1063+
},
1064+
},
10441065
}
10451066
for _, test := range testCases {
10461067
test.run(t, "forceConsistentCasingInFileNames")
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
currentDirectory::/home/src/workspaces/project
2+
useCaseSensitiveFileNames::true
3+
Input::
4+
//// [/home/src/workspaces/project/D.ts] *new*
5+
export const x = 10;
6+
//// [/home/src/workspaces/project/c.ts] *new*
7+
import {x} from "./D"
8+
//// [/home/src/workspaces/project/d.ts] *new*
9+
export const y = 20;
10+
//// [/home/src/workspaces/project/tsconfig.json] *new*
11+
{
12+
"files": ["c.ts", "d.ts"]
13+
}
14+
15+
tsgo
16+
ExitStatus:: DiagnosticsPresent_OutputsGenerated
17+
Output::
18+
error TS1149: File name '/home/src/workspaces/project/d.ts' differs from already included file name '/home/src/workspaces/project/D.ts' only in casing.
19+
The file is in the program because:
20+
Part of 'files' list in tsconfig.json
21+
tsconfig.json:2:23 - File is matched by 'files' list specified here.
22+
2 "files": ["c.ts", "d.ts"]
23+
   ~~~~~~
24+
25+
26+
Found 1 error.
27+
28+
//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib*
29+
/// <reference no-default-lib="true"/>
30+
interface Boolean {}
31+
interface Function {}
32+
interface CallableFunction {}
33+
interface NewableFunction {}
34+
interface IArguments {}
35+
interface Number { toExponential: any; }
36+
interface Object {}
37+
interface RegExp {}
38+
interface String { charAt: any; }
39+
interface Array<T> { length: number; [n: number]: T; }
40+
interface ReadonlyArray<T> {}
41+
interface SymbolConstructor {
42+
(desc?: string | number): symbol;
43+
for(name: string): symbol;
44+
readonly toStringTag: symbol;
45+
}
46+
declare var Symbol: SymbolConstructor;
47+
interface Symbol {
48+
readonly [Symbol.toStringTag]: string;
49+
}
50+
declare const console: { log(msg: any): void; };
51+
//// [/home/src/workspaces/project/D.js] *new*
52+
"use strict";
53+
Object.defineProperty(exports, "__esModule", { value: true });
54+
exports.x = void 0;
55+
exports.x = 10;
56+
57+
//// [/home/src/workspaces/project/c.js] *new*
58+
"use strict";
59+
Object.defineProperty(exports, "__esModule", { value: true });
60+
61+
//// [/home/src/workspaces/project/d.js] *new*
62+
"use strict";
63+
Object.defineProperty(exports, "__esModule", { value: true });
64+
exports.y = void 0;
65+
exports.y = 20;
66+
67+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
currentDirectory::/home/src/workspaces/project
2+
useCaseSensitiveFileNames::false
3+
Input::
4+
//// [/home/src/workspaces/project/src/c.ts] *new*
5+
/// <reference path="./D.ts"/>
6+
//// [/home/src/workspaces/project/src/d.ts] *new*
7+
declare class c { }
8+
//// [/home/src/workspaces/project/tsconfig.json] *new*
9+
{ }
10+
11+
tsgo
12+
ExitStatus:: DiagnosticsPresent_OutputsGenerated
13+
Output::
14+
src/c.ts:1:22 - error TS1261: Already included file name '/home/src/workspaces/project/src/D.ts' differs from file name '/home/src/workspaces/project/src/d.ts' only in casing.
15+
The file is in the program because:
16+
Referenced via './D.ts' from file '/home/src/workspaces/project/src/c.ts'
17+
Matched by default include pattern '**/*'
18+
19+
1 /// <reference path="./D.ts"/>
20+
   ~~~~~~
21+
22+
23+
Found 1 error in src/c.ts:1
24+
25+
//// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib*
26+
/// <reference no-default-lib="true"/>
27+
interface Boolean {}
28+
interface Function {}
29+
interface CallableFunction {}
30+
interface NewableFunction {}
31+
interface IArguments {}
32+
interface Number { toExponential: any; }
33+
interface Object {}
34+
interface RegExp {}
35+
interface String { charAt: any; }
36+
interface Array<T> { length: number; [n: number]: T; }
37+
interface ReadonlyArray<T> {}
38+
interface SymbolConstructor {
39+
(desc?: string | number): symbol;
40+
for(name: string): symbol;
41+
readonly toStringTag: symbol;
42+
}
43+
declare var Symbol: SymbolConstructor;
44+
interface Symbol {
45+
readonly [Symbol.toStringTag]: string;
46+
}
47+
declare const console: { log(msg: any): void; };
48+
//// [/home/src/workspaces/project/src/D.js] *new*
49+
50+
//// [/home/src/workspaces/project/src/c.js] *new*
51+
/// <reference path="./D.ts"/>
52+
53+

0 commit comments

Comments
 (0)