From b345c3a563a9ec66660075297ad50ac1d195e5a3 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Tue, 28 Mar 2023 09:50:12 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Pick=20PR=20#53443=20(Support=20?= =?UTF-8?q?wildcard=20exports=20in=20tsconfi...)=20into=20release-5.0=20(#?= =?UTF-8?q?53557)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Andrew Branch --- src/compiler/moduleNameResolver.ts | 2 +- ...tendsPackageJsonExportsWildcard.errors.txt | 30 +++++++++++++++++++ ...configExtendsPackageJsonExportsWildcard.ts | 27 +++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/tsconfigExtendsPackageJsonExportsWildcard.errors.txt create mode 100644 tests/cases/compiler/tsconfigExtendsPackageJsonExportsWildcard.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index e24f647c99c2f..a673672119cf3 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -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 { diff --git a/tests/baselines/reference/tsconfigExtendsPackageJsonExportsWildcard.errors.txt b/tests/baselines/reference/tsconfigExtendsPackageJsonExportsWildcard.errors.txt new file mode 100644 index 0000000000000..1cc129214b666 --- /dev/null +++ b/tests/baselines/reference/tsconfigExtendsPackageJsonExportsWildcard.errors.txt @@ -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. + \ No newline at end of file diff --git a/tests/cases/compiler/tsconfigExtendsPackageJsonExportsWildcard.ts b/tests/cases/compiler/tsconfigExtendsPackageJsonExportsWildcard.ts new file mode 100644 index 0000000000000..1caadbb1260b1 --- /dev/null +++ b/tests/cases/compiler/tsconfigExtendsPackageJsonExportsWildcard.ts @@ -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();