Skip to content

Commit 431f0d6

Browse files
committed
Add test case for #30429
1 parent 6a559e3 commit 431f0d6

5 files changed

+265
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//// [tests/cases/compiler/moduleResolutionPackageIdWithRelativeAndAbsolutePath.ts] ////
2+
3+
//// [package.json]
4+
{
5+
"name": "troublesome-lib",
6+
"version": "1.17.1"
7+
}
8+
//// [Compactable.d.ts]
9+
import { Option } from './Option';
10+
export class Compactable {
11+
option: Option;
12+
}
13+
//// [Option.d.ts]
14+
export class Option {
15+
someProperty: string;
16+
}
17+
//// [app.d.ts]
18+
import { Option } from "troublesome-lib/lib/Option";
19+
export class SharedOption extends Option { }
20+
export const makeSharedOption: () => SharedOption;
21+
//// [index.d.ts]
22+
import { Compactable } from "troublesome-lib/lib/Compactable"; // Including this will resolve Option as relative through the imports of compactable
23+
//// [package.json]
24+
{
25+
"name": "troublesome-lib",
26+
"version": "1.17.1"
27+
}
28+
//// [Compactable.d.ts]
29+
import { Option } from './Option';
30+
export class Compactable {
31+
option: Option;
32+
}
33+
//// [Option.d.ts]
34+
export class Option {
35+
someProperty: string;
36+
}
37+
//// [app.ts]
38+
import * as t from "anotherLib"; // Include the lib that recursively includes option as relative module resolution in this directory
39+
import { makeSharedOption } from "@shared/lib/app"; // Includes option as module in shared folder but as module in node_modules folder
40+
41+
42+
//// [/project/src/app.js]
43+
"use strict";
44+
exports.__esModule = true;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
=== /project/src/app.ts ===
2+
import * as t from "anotherLib"; // Include the lib that recursively includes option as relative module resolution in this directory
3+
>t : Symbol(t, Decl(app.ts, 0, 6))
4+
5+
import { makeSharedOption } from "@shared/lib/app"; // Includes option as module in shared folder but as module in node_modules folder
6+
>makeSharedOption : Symbol(makeSharedOption, Decl(app.ts, 1, 8))
7+
8+
=== /shared/node_modules/troublesome-lib/lib/Option.d.ts ===
9+
export class Option {
10+
>Option : Symbol(Option, Decl(Option.d.ts, 0, 0))
11+
12+
someProperty: string;
13+
>someProperty : Symbol(Option.someProperty, Decl(Option.d.ts, 0, 21))
14+
}
15+
=== /shared/lib/app.d.ts ===
16+
import { Option } from "troublesome-lib/lib/Option";
17+
>Option : Symbol(Option, Decl(app.d.ts, 0, 8))
18+
19+
export class SharedOption extends Option { }
20+
>SharedOption : Symbol(SharedOption, Decl(app.d.ts, 0, 52))
21+
>Option : Symbol(Option, Decl(app.d.ts, 0, 8))
22+
23+
export const makeSharedOption: () => SharedOption;
24+
>makeSharedOption : Symbol(makeSharedOption, Decl(app.d.ts, 2, 12))
25+
>SharedOption : Symbol(SharedOption, Decl(app.d.ts, 0, 52))
26+
27+
=== /project/node_modules/anotherLib/index.d.ts ===
28+
import { Compactable } from "troublesome-lib/lib/Compactable"; // Including this will resolve Option as relative through the imports of compactable
29+
>Compactable : Symbol(Compactable, Decl(index.d.ts, 0, 8))
30+
31+
=== /project/node_modules/troublesome-lib/lib/Compactable.d.ts ===
32+
import { Option } from './Option';
33+
>Option : Symbol(Option, Decl(Compactable.d.ts, 0, 8))
34+
35+
export class Compactable {
36+
>Compactable : Symbol(Compactable, Decl(Compactable.d.ts, 0, 34))
37+
38+
option: Option;
39+
>option : Symbol(Compactable.option, Decl(Compactable.d.ts, 1, 26))
40+
>Option : Symbol(Option, Decl(Compactable.d.ts, 0, 8))
41+
}
42+
=== /project/node_modules/troublesome-lib/lib/Option.d.ts ===
43+
export class Option {
44+
>Option : Symbol(Option, Decl(Option.d.ts, 0, 0))
45+
46+
someProperty: string;
47+
>someProperty : Symbol(Option.someProperty, Decl(Option.d.ts, 0, 21))
48+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[
2+
"======== Resolving module 'anotherLib' from '/project/src/app.ts'. ========",
3+
"Module resolution kind is not specified, using 'NodeJs'.",
4+
"'baseUrl' option is set to '/project', using this value to resolve non-relative module name 'anotherLib'.",
5+
"'paths' option is specified, looking for a pattern to match module name 'anotherLib'.",
6+
"'baseUrl' option is set to '/project', using this value to resolve non-relative module name 'anotherLib'.",
7+
"Resolving module name 'anotherLib' relative to base url '/project' - '/project/anotherLib'.",
8+
"Loading module as file / folder, candidate module location '/project/anotherLib', target file type 'TypeScript'.",
9+
"File '/project/anotherLib.ts' does not exist.",
10+
"File '/project/anotherLib.tsx' does not exist.",
11+
"File '/project/anotherLib.d.ts' does not exist.",
12+
"Directory '/project/anotherLib' does not exist, skipping all lookups in it.",
13+
"Loading module 'anotherLib' from 'node_modules' folder, target file type 'TypeScript'.",
14+
"Directory '/project/src/node_modules' does not exist, skipping all lookups in it.",
15+
"File '/project/node_modules/anotherLib/package.json' does not exist.",
16+
"File '/project/node_modules/anotherLib.ts' does not exist.",
17+
"File '/project/node_modules/anotherLib.tsx' does not exist.",
18+
"File '/project/node_modules/anotherLib.d.ts' does not exist.",
19+
"File '/project/node_modules/anotherLib/index.ts' does not exist.",
20+
"File '/project/node_modules/anotherLib/index.tsx' does not exist.",
21+
"File '/project/node_modules/anotherLib/index.d.ts' exist - use it as a name resolution result.",
22+
"Resolving real path for '/project/node_modules/anotherLib/index.d.ts', result '/project/node_modules/anotherLib/index.d.ts'.",
23+
"======== Module name 'anotherLib' was successfully resolved to '/project/node_modules/anotherLib/index.d.ts'. ========",
24+
"======== Resolving module '@shared/lib/app' from '/project/src/app.ts'. ========",
25+
"Module resolution kind is not specified, using 'NodeJs'.",
26+
"'baseUrl' option is set to '/project', using this value to resolve non-relative module name '@shared/lib/app'.",
27+
"'paths' option is specified, looking for a pattern to match module name '@shared/lib/app'.",
28+
"Module name '@shared/lib/app', matched pattern '@shared/*'.",
29+
"Trying substitution '../shared/*', candidate module location: '../shared/lib/app'.",
30+
"Loading module as file / folder, candidate module location '/shared/lib/app', target file type 'TypeScript'.",
31+
"File '/shared/lib/app.ts' does not exist.",
32+
"File '/shared/lib/app.tsx' does not exist.",
33+
"File '/shared/lib/app.d.ts' exist - use it as a name resolution result.",
34+
"======== Module name '@shared/lib/app' was successfully resolved to '/shared/lib/app.d.ts'. ========",
35+
"======== Resolving module 'troublesome-lib/lib/Compactable' from '/project/node_modules/anotherLib/index.d.ts'. ========",
36+
"Module resolution kind is not specified, using 'NodeJs'.",
37+
"'baseUrl' option is set to '/project', using this value to resolve non-relative module name 'troublesome-lib/lib/Compactable'.",
38+
"'paths' option is specified, looking for a pattern to match module name 'troublesome-lib/lib/Compactable'.",
39+
"'baseUrl' option is set to '/project', using this value to resolve non-relative module name 'troublesome-lib/lib/Compactable'.",
40+
"Resolving module name 'troublesome-lib/lib/Compactable' relative to base url '/project' - '/project/troublesome-lib/lib/Compactable'.",
41+
"Loading module as file / folder, candidate module location '/project/troublesome-lib/lib/Compactable', target file type 'TypeScript'.",
42+
"Loading module 'troublesome-lib/lib/Compactable' from 'node_modules' folder, target file type 'TypeScript'.",
43+
"Directory '/project/node_modules/anotherLib/node_modules' does not exist, skipping all lookups in it.",
44+
"'package.json' does not have a 'typesVersions' field.",
45+
"Found 'package.json' at '/project/node_modules/troublesome-lib/package.json'. Package ID is 'troublesome-lib/lib/Compactable/[email protected]'.",
46+
"File '/project/node_modules/troublesome-lib/lib/Compactable.ts' does not exist.",
47+
"File '/project/node_modules/troublesome-lib/lib/Compactable.tsx' does not exist.",
48+
"File '/project/node_modules/troublesome-lib/lib/Compactable.d.ts' exist - use it as a name resolution result.",
49+
"Resolving real path for '/project/node_modules/troublesome-lib/lib/Compactable.d.ts', result '/project/node_modules/troublesome-lib/lib/Compactable.d.ts'.",
50+
"======== Module name 'troublesome-lib/lib/Compactable' was successfully resolved to '/project/node_modules/troublesome-lib/lib/Compactable.d.ts'. ========",
51+
"======== Resolving module './Option' from '/project/node_modules/troublesome-lib/lib/Compactable.d.ts'. ========",
52+
"Module resolution kind is not specified, using 'NodeJs'.",
53+
"Loading module as file / folder, candidate module location '/project/node_modules/troublesome-lib/lib/Option', target file type 'TypeScript'.",
54+
"File '/project/node_modules/troublesome-lib/lib/Option.ts' does not exist.",
55+
"File '/project/node_modules/troublesome-lib/lib/Option.tsx' does not exist.",
56+
"File '/project/node_modules/troublesome-lib/lib/Option.d.ts' exist - use it as a name resolution result.",
57+
"'package.json' does not have a 'typesVersions' field.",
58+
"Found 'package.json' at '/project/node_modules/troublesome-lib/package.json'. Package ID is 'troublesome-lib/lib/[email protected]'.",
59+
"======== Module name './Option' was successfully resolved to '/project/node_modules/troublesome-lib/lib/Option.d.ts'. ========",
60+
"======== Resolving module 'troublesome-lib/lib/Option' from '/shared/lib/app.d.ts'. ========",
61+
"Module resolution kind is not specified, using 'NodeJs'.",
62+
"'baseUrl' option is set to '/project', using this value to resolve non-relative module name 'troublesome-lib/lib/Option'.",
63+
"'paths' option is specified, looking for a pattern to match module name 'troublesome-lib/lib/Option'.",
64+
"'baseUrl' option is set to '/project', using this value to resolve non-relative module name 'troublesome-lib/lib/Option'.",
65+
"Resolving module name 'troublesome-lib/lib/Option' relative to base url '/project' - '/project/troublesome-lib/lib/Option'.",
66+
"Loading module as file / folder, candidate module location '/project/troublesome-lib/lib/Option', target file type 'TypeScript'.",
67+
"Loading module 'troublesome-lib/lib/Option' from 'node_modules' folder, target file type 'TypeScript'.",
68+
"Directory '/shared/lib/node_modules' does not exist, skipping all lookups in it.",
69+
"'package.json' does not have a 'typesVersions' field.",
70+
"Found 'package.json' at '/shared/node_modules/troublesome-lib/package.json'. Package ID is 'troublesome-lib/lib/Option/[email protected]'.",
71+
"File '/shared/node_modules/troublesome-lib/lib/Option.ts' does not exist.",
72+
"File '/shared/node_modules/troublesome-lib/lib/Option.tsx' does not exist.",
73+
"File '/shared/node_modules/troublesome-lib/lib/Option.d.ts' exist - use it as a name resolution result.",
74+
"Resolving real path for '/shared/node_modules/troublesome-lib/lib/Option.d.ts', result '/shared/node_modules/troublesome-lib/lib/Option.d.ts'.",
75+
"======== Module name 'troublesome-lib/lib/Option' was successfully resolved to '/shared/node_modules/troublesome-lib/lib/Option.d.ts'. ========"
76+
]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
=== /project/src/app.ts ===
2+
import * as t from "anotherLib"; // Include the lib that recursively includes option as relative module resolution in this directory
3+
>t : typeof t
4+
5+
import { makeSharedOption } from "@shared/lib/app"; // Includes option as module in shared folder but as module in node_modules folder
6+
>makeSharedOption : () => import("/shared/lib/app").SharedOption
7+
8+
=== /shared/node_modules/troublesome-lib/lib/Option.d.ts ===
9+
export class Option {
10+
>Option : Option
11+
12+
someProperty: string;
13+
>someProperty : string
14+
}
15+
=== /shared/lib/app.d.ts ===
16+
import { Option } from "troublesome-lib/lib/Option";
17+
>Option : typeof Option
18+
19+
export class SharedOption extends Option { }
20+
>SharedOption : SharedOption
21+
>Option : Option
22+
23+
export const makeSharedOption: () => SharedOption;
24+
>makeSharedOption : () => SharedOption
25+
26+
=== /project/node_modules/anotherLib/index.d.ts ===
27+
import { Compactable } from "troublesome-lib/lib/Compactable"; // Including this will resolve Option as relative through the imports of compactable
28+
>Compactable : typeof Compactable
29+
30+
=== /project/node_modules/troublesome-lib/lib/Compactable.d.ts ===
31+
import { Option } from './Option';
32+
>Option : typeof Option
33+
34+
export class Compactable {
35+
>Compactable : Compactable
36+
37+
option: Option;
38+
>option : Option
39+
}
40+
=== /project/node_modules/troublesome-lib/lib/Option.d.ts ===
41+
export class Option {
42+
>Option : Option
43+
44+
someProperty: string;
45+
>someProperty : string
46+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// @noImplicitReferences: true
2+
// @fullEmitPaths: true
3+
// @traceResolution: true
4+
// @filename: /shared/node_modules/troublesome-lib/package.json
5+
{
6+
"name": "troublesome-lib",
7+
"version": "1.17.1"
8+
}
9+
// @filename: /shared/node_modules/troublesome-lib/lib/Compactable.d.ts
10+
import { Option } from './Option';
11+
export class Compactable {
12+
option: Option;
13+
}
14+
// @filename: /shared/node_modules/troublesome-lib/lib/Option.d.ts
15+
export class Option {
16+
someProperty: string;
17+
}
18+
// @filename: /shared/lib/app.d.ts
19+
import { Option } from "troublesome-lib/lib/Option";
20+
export class SharedOption extends Option { }
21+
export const makeSharedOption: () => SharedOption;
22+
// @filename: /project/node_modules/anotherLib/index.d.ts
23+
import { Compactable } from "troublesome-lib/lib/Compactable"; // Including this will resolve Option as relative through the imports of compactable
24+
// @filename: /project/node_modules/troublesome-lib/package.json
25+
{
26+
"name": "troublesome-lib",
27+
"version": "1.17.1"
28+
}
29+
// @filename: /project/node_modules/troublesome-lib/lib/Compactable.d.ts
30+
import { Option } from './Option';
31+
export class Compactable {
32+
option: Option;
33+
}
34+
// @filename: /project/node_modules/troublesome-lib/lib/Option.d.ts
35+
export class Option {
36+
someProperty: string;
37+
}
38+
// @filename: /project/src/app.ts
39+
import * as t from "anotherLib"; // Include the lib that recursively includes option as relative module resolution in this directory
40+
import { makeSharedOption } from "@shared/lib/app"; // Includes option as module in shared folder but as module in node_modules folder
41+
42+
// @filename: /project/tsconfig.json
43+
{
44+
"compilerOptions": {
45+
"baseUrl": ".",
46+
"paths": {
47+
"@shared/*": ["../shared/*"]
48+
}
49+
},
50+
//"files": ["src/app.ts"]
51+
}

0 commit comments

Comments
 (0)