-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add path completions for package.json exports with wildcards #49644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d652e2c
Support path completions for exports wildcards
andrewbranch 6fd9c2b
Break up results by directory
andrewbranch f531be7
Share code between typesVersions and exports processing
andrewbranch 426545c
Revert completion kind change
andrewbranch 179d1cb
Add kinds to tests
andrewbranch ed77c7c
Update existing test
andrewbranch 7480024
Support nested conditions, improve recursive globbing
andrewbranch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard1.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: nodenext | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "name": "foo", | ||
//// "main": "dist/index.js", | ||
//// "module": "dist/index.mjs", | ||
//// "types": "dist/index.d.ts", | ||
//// "exports": { | ||
//// ".": { | ||
//// "types": "./dist/index.d.ts", | ||
andrewbranch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//// "import": "./dist/index.mjs", | ||
//// "default": "./dist/index.js" | ||
//// }, | ||
//// "./*": { | ||
//// "types": "./dist/*.d.ts", | ||
//// "import": "./dist/*.mjs", | ||
//// "default": "./dist/*.js" | ||
//// }, | ||
//// "./arguments": { | ||
//// "types": "./dist/arguments/index.d.ts", | ||
//// "import": "./dist/arguments/index.mjs", | ||
//// "default": "./dist/arguments/index.js" | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @Filename: /node_modules/foo/dist/index.d.ts | ||
//// export const index = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/blah.d.ts | ||
//// export const blah = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/arguments/index.d.ts | ||
//// export const arguments = 0; | ||
|
||
// @Filename: /index.mts | ||
//// import { } from "foo//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: [ | ||
{ name: "blah", kind: "script", kindModifiers: "" }, | ||
{ name: "index", kind: "script", kindModifiers: "" }, | ||
{ name: "arguments", kind: "script", kindModifiers: "" }, | ||
] | ||
}); |
42 changes: 42 additions & 0 deletions
42
tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard2.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: nodenext | ||
|
||
// @Filename: /node_modules/salesforce-pageobjects/package.json | ||
//// { | ||
//// "name": "salesforce-pageobjects", | ||
//// "version": "1.0.0", | ||
//// "exports": { | ||
//// "./*": { | ||
//// "types": "./dist/*.d.ts", | ||
//// "import": "./dist/*.mjs", | ||
//// "default": "./dist/*.js" | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @Filename: /node_modules/salesforce-pageobjects/dist/action/pageObjects/actionRenderer.d.ts | ||
//// export const actionRenderer = 0; | ||
|
||
// @Filename: /index.mts | ||
//// import { } from "salesforce-pageobjects//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: [{ name: "action", kind: "directory" }] | ||
}); | ||
|
||
edit.insert("action/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: [{ name: "pageObjects", kind: "directory" }], | ||
}); | ||
|
||
edit.insert("pageObjects/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: [{ name: "actionRenderer", kind: "script" }], | ||
}); |
45 changes: 45 additions & 0 deletions
45
tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard3.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: nodenext | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "types": "index.d.ts", | ||
//// "exports": { | ||
//// "./component-*": { | ||
//// "types@>=4.3.5": "types/components/*.d.ts" | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @Filename: /node_modules/foo/nope.d.ts | ||
//// export const nope = 0; | ||
|
||
// @Filename: /node_modules/foo/types/components/index.d.ts | ||
//// export const index = 0; | ||
|
||
// @Filename: /node_modules/foo/types/components/blah.d.ts | ||
//// export const blah = 0; | ||
|
||
// @Filename: /node_modules/foo/types/components/subfolder/one.d.ts | ||
//// export const one = 0; | ||
|
||
// @Filename: /a.ts | ||
//// import { } from "foo//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: [ | ||
{ name: "component-blah", kind: "script" }, | ||
{ name: "component-index", kind: "script" }, | ||
{ name: "component-subfolder", kind: "directory" }, | ||
], | ||
}); | ||
|
||
edit.insert("component-subfolder/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: [{ name: "one", kind: "script" }], | ||
}); |
64 changes: 64 additions & 0 deletions
64
tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard4.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: nodenext | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "types": "index.d.ts", | ||
//// "exports": { | ||
//// "./*": "dist/*", | ||
//// "./foo/*": "dist/*", | ||
//// "./bar/*": "dist/*", | ||
//// "./exact-match": "dist/index.d.ts" | ||
//// } | ||
//// } | ||
|
||
// @Filename: /node_modules/foo/nope.d.ts | ||
//// export const nope = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/index.d.ts | ||
//// export const index = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/blah.d.ts | ||
//// export const blah = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/foo/onlyInFooFolder.d.ts | ||
//// export const foo = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/subfolder/one.d.ts | ||
//// export const one = 0; | ||
|
||
// @Filename: /a.mts | ||
//// import { } from "foo//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: [ | ||
{ name: "blah.js", kind: "script", kindModifiers: ".js" }, | ||
{ name: "index.js", kind: "script", kindModifiers: ".js" }, | ||
{ name: "foo", kind: "directory" }, | ||
{ name: "subfolder", kind: "directory" }, | ||
{ name: "bar", kind: "directory" }, | ||
{ name: "exact-match", kind: "script" }, | ||
], | ||
}); | ||
|
||
edit.insert("foo/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: [ | ||
{ name: "blah.js", kind: "script", kindModifiers: ".js" }, | ||
{ name: "index.js", kind: "script", kindModifiers: ".js" }, | ||
{ name: "foo", kind: "directory" }, | ||
{ name: "subfolder", kind: "directory" }, | ||
], | ||
}); | ||
|
||
edit.insert("foo/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: [{ name: "onlyInFooFolder.js", kind: "script", kindModifiers: ".js" }], | ||
}); |
66 changes: 66 additions & 0 deletions
66
tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard5.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: nodenext | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "name": "foo", | ||
//// "main": "dist/index.js", | ||
//// "module": "dist/index.mjs", | ||
//// "types": "dist/index.d.ts", | ||
//// "exports": { | ||
//// ".": { | ||
//// "import": { | ||
//// "types": "./dist/types/index.d.mts", | ||
//// "default": "./dist/esm/index.mjs" | ||
//// }, | ||
//// "default": { | ||
//// "types": "./dist/types/index.d.ts", | ||
//// "default": "./dist/cjs/index.js" | ||
//// } | ||
//// }, | ||
//// "./*": { | ||
//// "import": { | ||
//// "types": "./dist/types/*.d.mts", | ||
//// "default": "./dist/esm/*.mjs" | ||
//// }, | ||
//// "default": { | ||
//// "types": "./dist/types/*.d.ts", | ||
//// "default": "./dist/cjs/*.js" | ||
//// } | ||
//// }, | ||
//// "./only-in-cjs": { | ||
//// "require": { | ||
//// "types": "./dist/types/only-in-cjs/index.d.ts", | ||
//// "default": "./dist/cjs/only-in-cjs/index.js" | ||
//// } | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @Filename: /node_modules/foo/dist/types/index.d.mts | ||
//// export const index = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/types/index.d.ts | ||
//// export const index = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/types/blah.d.mts | ||
//// export const blah = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/types/blah.d.ts | ||
//// export const blah = 0; | ||
|
||
// @Filename: /node_modules/foo/dist/types/only-in-cjs/index.d.ts | ||
//// export const onlyInCjs = 0; | ||
|
||
// @Filename: /index.mts | ||
//// import { } from "foo//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: [ | ||
{ name: "blah", kind: "script", kindModifiers: "" }, | ||
{ name: "index", kind: "script", kindModifiers: "" }, | ||
] | ||
}); |
31 changes: 31 additions & 0 deletions
31
tests/cases/fourslash/pathCompletionsPackageJsonExportsWildcard6.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: nodenext | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "name": "foo", | ||
//// "main": "dist/index.js", | ||
//// "module": "dist/index.mjs", | ||
//// "types": "dist/index.d.ts", | ||
//// "exports": { | ||
//// "./*": "./dist/*?.d.ts" | ||
//// } | ||
//// } | ||
|
||
// @Filename: /node_modules/foo/dist/index.d.ts | ||
//// export const index = 0; | ||
|
||
// @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: "" }, | ||
] | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.