Support wildcard exports in tsconfig lookup (#53443)

This commit is contained in:
Andrew Branch 2023-03-22 15:21:50 -07:00 committed by GitHub
parent f6f6cb893f
commit 7009c76d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 1 deletions

View File

@ -1689,7 +1689,7 @@ export function nodeModuleNameResolver(moduleName: string, containingFile: strin
/** @internal */
export function nodeNextJsonConfigResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
return nodeModuleNameResolverWorker(NodeResolutionFeatures.Exports, moduleName, getDirectoryPath(containingFile), { moduleResolution: ModuleResolutionKind.NodeNext }, host, /*cache*/ undefined, Extensions.Json, /*isConfigLookup*/ true, /*redirectedReference*/ undefined);
return nodeModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, getDirectoryPath(containingFile), { moduleResolution: ModuleResolutionKind.NodeNext }, host, /*cache*/ undefined, Extensions.Json, /*isConfigLookup*/ true, /*redirectedReference*/ undefined);
}
function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleName: string, containingDirectory: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache: ModuleResolutionCache | undefined, extensions: Extensions, isConfigLookup: boolean, redirectedReference: ResolvedProjectReference | undefined): ResolvedModuleWithFailedLookupLocations {

View File

@ -0,0 +1,30 @@
/index.ts(2,1): error TS2454: Variable 'x' is used before being assigned.
==== /tsconfig.json (0 errors) ====
{
"extends": "foo/strict.json"
}
==== /node_modules/foo/package.json (0 errors) ====
{
"name": "foo",
"version": "1.0.0",
"exports": {
"./*.json": "./configs/*.json"
}
}
==== /node_modules/foo/configs/strict.json (0 errors) ====
{
"compilerOptions": {
"strict": true
}
}
==== /index.ts (1 errors) ====
let x: string;
x.toLowerCase();
~
!!! error TS2454: Variable 'x' is used before being assigned.

View File

@ -0,0 +1,27 @@
// @noTypesAndSymbols: true
// @noEmit: true
// @Filename: /node_modules/foo/package.json
{
"name": "foo",
"version": "1.0.0",
"exports": {
"./*.json": "./configs/*.json"
}
}
// @Filename: /node_modules/foo/configs/strict.json
{
"compilerOptions": {
"strict": true
}
}
// @Filename: /tsconfig.json
{
"extends": "foo/strict.json"
}
// @Filename: /index.ts
let x: string;
x.toLowerCase();