mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Use custom conditions in path completions (#54332)
This commit is contained in:
parent
b03926ea78
commit
d49a28534a
@ -44,6 +44,7 @@ import {
|
||||
flatten,
|
||||
forEachAncestorDirectory,
|
||||
getBaseFileName,
|
||||
getConditions,
|
||||
getContextualTypeFromParent,
|
||||
getDirectoryPath,
|
||||
getEffectiveTypeRoots,
|
||||
@ -924,7 +925,7 @@ function getCompletionEntriesForNonRelativeModules(
|
||||
}
|
||||
const keys = getOwnKeys(exports);
|
||||
const fragmentSubpath = components.join("/") + (components.length && hasTrailingDirectorySeparator(fragment) ? "/" : "");
|
||||
const conditions = mode === ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"];
|
||||
const conditions = getConditions(compilerOptions, mode === ModuleKind.ESNext);
|
||||
addCompletionEntriesFromPathsOrExports(
|
||||
result,
|
||||
fragmentSubpath,
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @moduleResolution: bundler
|
||||
|
||||
// @Filename: /node_modules/foo/package.json
|
||||
//// {
|
||||
//// "name": "foo",
|
||||
//// "exports": {
|
||||
//// "./only-for-node": {
|
||||
//// "node": "./something.js"
|
||||
//// },
|
||||
//// "./for-everywhere": "./other.js",
|
||||
//// }
|
||||
//// }
|
||||
|
||||
// @Filename: /node_modules/foo/something.d.ts
|
||||
//// export const index = 0;
|
||||
|
||||
// @Filename: /node_modules/foo/other.d.ts
|
||||
//// export const index = 0;
|
||||
|
||||
// @Filename: /index.ts
|
||||
//// import { } from "foo//**/";
|
||||
|
||||
verify.completions({
|
||||
marker: "",
|
||||
isNewIdentifierLocation: true,
|
||||
exact: [
|
||||
{ name: "for-everywhere", kind: "script", kindModifiers: "" },
|
||||
]
|
||||
});
|
||||
@ -0,0 +1,28 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @module: nodenext
|
||||
// @customConditions: custom-condition
|
||||
|
||||
// @Filename: /node_modules/foo/package.json
|
||||
//// {
|
||||
//// "name": "foo",
|
||||
//// "exports": {
|
||||
//// "./only-with-custom-conditions": {
|
||||
//// "custom-condition": "./something.js"
|
||||
//// },
|
||||
//// }
|
||||
//// }
|
||||
|
||||
// @Filename: /node_modules/foo/something.d.ts
|
||||
//// export const index = 0;
|
||||
|
||||
// @Filename: /index.ts
|
||||
//// import { } from "foo//**/";
|
||||
|
||||
verify.completions({
|
||||
marker: "",
|
||||
isNewIdentifierLocation: true,
|
||||
exact: [
|
||||
{ name: "only-with-custom-conditions", kind: "script", kindModifiers: "" },
|
||||
]
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user