Skip to content

Commit 7009c76

Browse files
authored
Support wildcard exports in tsconfig lookup (microsoft#53443)
1 parent f6f6cb8 commit 7009c76

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

src/compiler/moduleNameResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ export function nodeModuleNameResolver(moduleName: string, containingFile: strin
16891689

16901690
/** @internal */
16911691
export function nodeNextJsonConfigResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
1692-
return nodeModuleNameResolverWorker(NodeResolutionFeatures.Exports, moduleName, getDirectoryPath(containingFile), { moduleResolution: ModuleResolutionKind.NodeNext }, host, /*cache*/ undefined, Extensions.Json, /*isConfigLookup*/ true, /*redirectedReference*/ undefined);
1692+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, getDirectoryPath(containingFile), { moduleResolution: ModuleResolutionKind.NodeNext }, host, /*cache*/ undefined, Extensions.Json, /*isConfigLookup*/ true, /*redirectedReference*/ undefined);
16931693
}
16941694

16951695
function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleName: string, containingDirectory: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache: ModuleResolutionCache | undefined, extensions: Extensions, isConfigLookup: boolean, redirectedReference: ResolvedProjectReference | undefined): ResolvedModuleWithFailedLookupLocations {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/index.ts(2,1): error TS2454: Variable 'x' is used before being assigned.
2+
3+
4+
==== /tsconfig.json (0 errors) ====
5+
{
6+
"extends": "foo/strict.json"
7+
}
8+
9+
==== /node_modules/foo/package.json (0 errors) ====
10+
{
11+
"name": "foo",
12+
"version": "1.0.0",
13+
"exports": {
14+
"./*.json": "./configs/*.json"
15+
}
16+
}
17+
18+
==== /node_modules/foo/configs/strict.json (0 errors) ====
19+
{
20+
"compilerOptions": {
21+
"strict": true
22+
}
23+
}
24+
25+
==== /index.ts (1 errors) ====
26+
let x: string;
27+
x.toLowerCase();
28+
~
29+
!!! error TS2454: Variable 'x' is used before being assigned.
30+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// @noTypesAndSymbols: true
2+
// @noEmit: true
3+
4+
// @Filename: /node_modules/foo/package.json
5+
{
6+
"name": "foo",
7+
"version": "1.0.0",
8+
"exports": {
9+
"./*.json": "./configs/*.json"
10+
}
11+
}
12+
13+
// @Filename: /node_modules/foo/configs/strict.json
14+
{
15+
"compilerOptions": {
16+
"strict": true
17+
}
18+
}
19+
20+
// @Filename: /tsconfig.json
21+
{
22+
"extends": "foo/strict.json"
23+
}
24+
25+
// @Filename: /index.ts
26+
let x: string;
27+
x.toLowerCase();

0 commit comments

Comments
 (0)