Skip to content

Commit

Permalink
Fix export path patterns with .d.ts target extensions in AutoImportPr…
Browse files Browse the repository at this point in the history
…ovider (microsoft#55815)
  • Loading branch information
andrewbranch authored and snovader committed Sep 23, 2023
1 parent 89caf30 commit fdb2124
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,11 @@ function loadEntrypointsFromExportMap(
scope.packageDirectory,
extensionsToExtensionsArray(extensions),
/*excludes*/ undefined,
[changeAnyExtension(target.replace("*", "**/*"), getDeclarationEmitExtensionForPath(target))],
[
isDeclarationFileName(target)
? target.replace("*", "**/*")
: changeAnyExtension(target.replace("*", "**/*"), getDeclarationEmitExtensionForPath(target)),
],
).forEach(entry => {
entrypoints = appendIfUnique(entrypoints, {
path: entry,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/// <reference path="../fourslash.ts" />

// @Filename: /node_modules/pkg/package.json
//// {
//// "name": "pkg",
//// "version": "1.0.0",
//// "exports": {
//// "./core/*": {
//// "types": "./lib/core/*.d.ts",
//// "default": "./lib/core/*.js"
//// }
//// }
//// }

// @Filename: /node_modules/pkg/lib/core/test.d.ts
//// export function test(): void;

// @Filename: /package.json
//// {
//// "type": "module",
//// "dependencies": {
//// "pkg": "1.0.0"
//// }
//// }

// @Filename: /tsconfig.json
//// {
//// "compilerOptions": {
//// "module": "nodenext"
//// }
//// }

// @Filename: /main.ts
//// /**/

verify.completions({
marker: "",
includes: [
{
name: "test",
source: "pkg/core/test",
sourceDisplay: "pkg/core/test",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions
},
],
preferences: {
includeCompletionsForModuleExports: true,
allowIncompleteCompletions: true
}
});

0 comments on commit fdb2124

Please sign in to comment.