mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 11:24:49 -05:00
fix: import keyword name (#54675)
Co-authored-by: Isabel Duan <iduan@hmc.edu>
This commit is contained in:
@@ -208,6 +208,7 @@ import {
|
||||
isNamedImportsOrExports,
|
||||
isNamespaceImport,
|
||||
isNodeDescendantOf,
|
||||
isNonContextualKeyword,
|
||||
isObjectBindingPattern,
|
||||
isObjectLiteralExpression,
|
||||
isObjectTypeDeclaration,
|
||||
@@ -1777,6 +1778,14 @@ function createCompletionEntry(
|
||||
hasAction = !importStatementCompletion;
|
||||
}
|
||||
|
||||
const parentNamedImportOrExport = findAncestor(location, isNamedImportsOrExports);
|
||||
if (parentNamedImportOrExport?.kind === SyntaxKind.NamedImports) {
|
||||
const possibleToken = stringToToken(name);
|
||||
if (parentNamedImportOrExport && possibleToken && (possibleToken === SyntaxKind.AwaitKeyword || isNonContextualKeyword(possibleToken))) {
|
||||
insertText = `${name} as ${name}_`;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(drosen): Right now we just permit *all* semantic meanings when calling
|
||||
// 'getSymbolKind' which is permissible given that it is backwards compatible; but
|
||||
// really we should consider passing the meaning for the node so that we don't report
|
||||
|
||||
Reference in New Issue
Block a user