mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 20:44:53 -05:00
For import completion of default import, convert module name to identifier (#19875)
* For import completion of default import, convert module name to identifier * Suggestions from code review
This commit is contained in:
@@ -294,7 +294,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function stringToToken(s: string): SyntaxKind {
|
||||
export function stringToToken(s: string): SyntaxKind | undefined {
|
||||
return textToToken.get(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace ts {
|
||||
UndefinedKeyword,
|
||||
FromKeyword,
|
||||
GlobalKeyword,
|
||||
OfKeyword, // LastKeyword and LastToken
|
||||
OfKeyword, // LastKeyword and LastToken and LastContextualKeyword
|
||||
|
||||
// Parse tree nodes
|
||||
|
||||
@@ -431,7 +431,9 @@ namespace ts {
|
||||
FirstJSDocNode = JSDocTypeExpression,
|
||||
LastJSDocNode = JSDocPropertyTag,
|
||||
FirstJSDocTagNode = JSDocTag,
|
||||
LastJSDocTagNode = JSDocPropertyTag
|
||||
LastJSDocTagNode = JSDocPropertyTag,
|
||||
/* @internal */ FirstContextualKeyword = AbstractKeyword,
|
||||
/* @internal */ LastContextualKeyword = OfKeyword,
|
||||
}
|
||||
|
||||
export const enum NodeFlags {
|
||||
|
||||
@@ -1905,6 +1905,14 @@ namespace ts {
|
||||
return SyntaxKind.FirstKeyword <= token && token <= SyntaxKind.LastKeyword;
|
||||
}
|
||||
|
||||
export function isContextualKeyword(token: SyntaxKind): boolean {
|
||||
return SyntaxKind.FirstContextualKeyword <= token && token <= SyntaxKind.LastContextualKeyword;
|
||||
}
|
||||
|
||||
export function isNonContextualKeyword(token: SyntaxKind): boolean {
|
||||
return isKeyword(token) && !isContextualKeyword(token);
|
||||
}
|
||||
|
||||
export function isTrivia(token: SyntaxKind) {
|
||||
return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user