Skip to content

Commit

Permalink
🤖 Pick PR #53443 (Support wildcard exports in tsconfi...) into releas…
Browse files Browse the repository at this point in the history
…e-5.0 (#53557)

Co-authored-by: Andrew Branch <andrew@wheream.io>
  • Loading branch information
TypeScript Bot and andrewbranch authored Mar 28, 2023
1 parent aebd31b commit b345c3a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

27 changes: 27 additions & 0 deletions tests/cases/compiler/tsconfigExtendsPackageJsonExportsWildcard.ts
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit b345c3a

Please sign in to comment.