polish html sem highlighting

This commit is contained in:
Martin Aeschlimann
2020-01-13 21:06:57 +01:00
parent 5e1dbb1096
commit a5f90a5685
2 changed files with 4 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ export function getSemanticTokens(jsLanguageService: ts.LanguageService, current
const typeChecker = program.getTypeChecker();
function visit(node: ts.Node) {
if (node.kind === ts.SyntaxKind.Identifier) {
if (ts.isIdentifier(node)) {
const symbol = typeChecker.getSymbolAtLocation(node);
if (symbol) {
let typeIdx = classifySymbol(symbol);
@@ -76,7 +76,7 @@ function classifySymbol(symbol: ts.Symbol) {
}
}
const decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0];
return tokenFromDeclarationMapping[decl.kind];
return decl && tokenFromDeclarationMapping[decl.kind];
}