Skip to content

Missing path completions for exports field patterns when relying on sibling .d.ts file lookup #54330

Closed
@emmatown

Description

@emmatown

Bug Report

🔎 Search Terms

path completions package.json exports pattern wildcard

🕗 Version & Regression Information

This is the behavior in every version I tried, and none of the FAQ entries are relevant. #49644 added path completions for exports fields patterns but it relies on pointing to a .d.ts file directly.

⏯ Playground Link

This can't be reproduced in the playground since it relies on a package.json.

💻 Code

As a failing fourslash test:

/// <reference path="fourslash.ts" />

// @module: nodenext

// @Filename: /node_modules/foo/package.json
//// {
////   "name": "foo",
////   "exports": {
////     "./*": "./dist/*.js"
////   }
//// }

// @Filename: /node_modules/foo/dist/blah.d.ts
//// export const blah = 0;

// @Filename: /index.mts
//// import { } from "foo//**/";

verify.completions({
  marker: "",
  isNewIdentifierLocation: true,
  exact: [
    { name: "blah", kind: "script", kindModifiers: "" },
  ]
});

It works if you update the package.json to this:

{
  "name": "foo",
  "exports": {
    "./*": {
      "types": "./dist/*.d.ts",
      "default": "./dist/*.js"
    }
  }
}

🙁 Actual behavior

Path completions are missing for patterns in package.json exports fields when pointing to a .js/.mjs/.cjs file and relying on TypeScript to load the sibling .d.ts/.d.mts/.d.cts file.

🙂 Expected behavior

Path completions shouldn't be affected by whether you're relying on sibling lookup or not, especially since the recommendation is to rely on it rather than use a types condition.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Completion ListsThe issue relates to showing completion lists in an editorFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions