Description
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.