-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix path completions for typesVersions (#49154)
* Fix path completions for typesVersions * Add more tests * Fix case when * is a fragment of a path component * Once a path pattern matches, only return completions from that pattern and higher priority ones * Fix iteration order issue * Aesthetics
- Loading branch information
1 parent
f6a1713
commit 0921eac
Showing
10 changed files
with
339 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
42 changes: 42 additions & 0 deletions
42
tests/cases/fourslash/pathCompletionsTypesVersionsWildcard1.ts
This file contains 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: commonjs | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "types": "index.d.ts", | ||
//// "typesVersions": { | ||
//// "*": { | ||
//// "*": ["dist/*"] | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @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/subfolder/one.d.ts | ||
//// export const one = 0; | ||
|
||
// @Filename: /a.ts | ||
//// import { } from "foo//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: ["blah", "index", "subfolder"], | ||
}); | ||
|
||
edit.insert("subfolder/"); | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: ["one"], | ||
}); |
34 changes: 34 additions & 0 deletions
34
tests/cases/fourslash/pathCompletionsTypesVersionsWildcard2.ts
This file contains 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,34 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: commonjs | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "types": "index.d.ts", | ||
//// "typesVersions": { | ||
//// "<=3.4.1": { | ||
//// "*": ["ts-old/*"] | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @Filename: /node_modules/foo/nope.d.ts | ||
//// export const nope = 0; | ||
|
||
// @Filename: /node_modules/foo/ts-old/index.d.ts | ||
//// export const index = 0; | ||
|
||
// @Filename: /node_modules/foo/ts-old/blah.d.ts | ||
//// export const blah = 0; | ||
|
||
// @Filename: /node_modules/foo/ts-old/subfolder/one.d.ts | ||
//// export const one = 0; | ||
|
||
// @Filename: /a.ts | ||
//// import { } from "foo//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: ["nope", "ts-old"], | ||
}); |
48 changes: 48 additions & 0 deletions
48
tests/cases/fourslash/pathCompletionsTypesVersionsWildcard3.ts
This file contains 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,48 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: commonjs | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "types": "index.d.ts", | ||
//// "typesVersions": { | ||
//// ">=4.3.5": { | ||
//// "browser/*": ["dist/*"] | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @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/subfolder/one.d.ts | ||
//// export const one = 0; | ||
|
||
// @Filename: /a.ts | ||
//// import { } from "foo//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: ["browser", "nope", "dist"], | ||
}); | ||
|
||
edit.insert("browser/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: ["blah", "index", "subfolder"], | ||
}); | ||
|
||
edit.insert("subfolder/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: ["one"], | ||
}); |
41 changes: 41 additions & 0 deletions
41
tests/cases/fourslash/pathCompletionsTypesVersionsWildcard4.ts
This file contains 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,41 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: commonjs | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "types": "index.d.ts", | ||
//// "typesVersions": { | ||
//// ">=4.3.5": { | ||
//// "component-*": ["cjs/components/*"] | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @Filename: /node_modules/foo/nope.d.ts | ||
//// export const nope = 0; | ||
|
||
// @Filename: /node_modules/foo/cjs/components/index.d.ts | ||
//// export const index = 0; | ||
|
||
// @Filename: /node_modules/foo/cjs/components/blah.d.ts | ||
//// export const blah = 0; | ||
|
||
// @Filename: /node_modules/foo/cjs/components/subfolder/one.d.ts | ||
//// export const one = 0; | ||
|
||
// @Filename: /a.ts | ||
//// import { } from "foo//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: ["component-blah", "component-index", "component-subfolder", "nope", "cjs"], | ||
}); | ||
|
||
edit.insert("component-subfolder/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: ["one"], | ||
}); |
54 changes: 54 additions & 0 deletions
54
tests/cases/fourslash/pathCompletionsTypesVersionsWildcard5.ts
This file contains 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,54 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: commonjs | ||
|
||
// @Filename: /node_modules/foo/package.json | ||
//// { | ||
//// "types": "index.d.ts", | ||
//// "typesVersions": { | ||
//// "*": { | ||
//// "*": ["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.ts | ||
//// import { } from "foo//**/"; | ||
|
||
verify.completions({ | ||
marker: "", | ||
isNewIdentifierLocation: true, | ||
exact: ["blah", "index", "foo", "subfolder", "bar", "exact-match"], | ||
}); | ||
|
||
edit.insert("foo/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: ["blah", "index", "foo", "subfolder"], | ||
}); | ||
|
||
edit.insert("foo/"); | ||
|
||
verify.completions({ | ||
isNewIdentifierLocation: true, | ||
exact: ["onlyInFooFolder"], | ||
}); |
Oops, something went wrong.