Open
Description
TypeScript Version: 2.1.1
Code
I'm trying to implement function detecting is identifier internal (can be renamed) or external but sometimes TS Compiler API returns me no symbols for identifiers:
private isIdentExternal(node: ts.Node): boolean {
// node here is only ts.Node with kind=65 (Identifier), and already checked not to be reserved word
let symbol = this.program.getTypeChecker().getSymbolAtLocation(node);
if (!symbol) {
// why?
}
for (const decl of symbol.declarations)
if (decl.getSourceFile().fileName.endsWith(".d.ts"))
return true;
return false;
}
There are two known cases when I get this problem.
Case 1: no symbol for internal abstract function:
abstract class Cls {
private abstract func();// no symbol is here
// Tough I can get symbols from cls.func() code in other place, the problem is for declaration only
}
Case 2: no symbol for external properties:
let el: HTMLElement = document.createElement("div");
el.className = "x"; // no symbol for "className", tough I have symbol for "createElement" (problem is only for properties)
Expected behavior:
Every identifier (function/variable/method/property/class definition) has symbol.
Actual behavior:
Sometimes symbol is missing (TypeChecker does not return it).