fix(52233): Ambient modules declared with patterns are offered in path completions (#52246)

This commit is contained in:
Oleksandr T 2023-01-17 19:41:16 +02:00 committed by GitHub
parent 243d8de66d
commit 577cc1bd8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View File

@ -1025,7 +1025,7 @@ function removeLeadingDirectorySeparator(path: string): string {
function getAmbientModuleCompletions(fragment: string, fragmentDirectory: string | undefined, checker: TypeChecker): readonly string[] {
// Get modules that the type checker picked up
const ambientModules = checker.getAmbientModules().map(sym => stripQuotes(sym.name));
const nonRelativeModuleNames = ambientModules.filter(moduleName => startsWith(moduleName, fragment));
const nonRelativeModuleNames = ambientModules.filter(moduleName => startsWith(moduleName, fragment) && moduleName.indexOf("*") < 0);
// Nested modules of the form "module-name/sub" need to be adjusted to only return the string
// after the last '/' that appears in the fragment because that's where the replacement span

View File

@ -0,0 +1,15 @@
[
{
"marker": {
"fileName": "/a.ts",
"position": 22,
"name": ""
},
"completionList": {
"isGlobalCompletion": false,
"isMemberCompletion": false,
"isNewIdentifierLocation": true,
"entries": []
}
}
]

View File

@ -0,0 +1,9 @@
/// <reference path="fourslash.ts" />
// @filename: /globals.d.ts
////declare module "*.css";
// @filename: /a.ts
////import * as foo from "/**/";
verify.baselineCompletions();