fix(typescript_indexer): fix compilation issues with TypeScript 4.3
In TypeScript 4.3, some DOM/compiler interfaces has changed.
@@ -580,11 +580,11 @@ class StandardIndexerContext implements IndexerHost {
const stored = this.symbolNames.get(sym, ns, context);
if (stored) return stored;
- let declarations = sym.declarations;
- if (!declarations || declarations.length < 1) {
+ if (!sym.declarations || sym.declarations.length < 1) {
return undefined;
}
+ let declarations = sym.declarations;
// Disambiguate symbols with multiple declarations using a context.
if (sym.declarations.length > 1) {
switch (context) {
@@ -1427,7 +1427,9 @@ class Visitor {
this.emitEdge(anchor, EdgeKind.DEFINES_BINDING, implicitProp);
const sym = this.host.getSymbolAtLocation(decl.name);
- if (!sym) throw new Error('Getter/setter declaration has no symbols.');
+ if (!sym || !sym.declarations) {
+ throw new Error('Getter/setter declaration has no symbols.');
+ }
if (sym.declarations.find(ts.isGetAccessor)) {
// Emit a "property/reads" edge between the getter and the property
@@ -1849,7 +1851,7 @@ class Visitor {
// getter is present, it will bind this entry; otherwise a setter will.
if (ts.isGetAccessor(decl) ||
(ts.isSetAccessor(decl) &&
- !sym.declarations.find(ts.isGetAccessor))) {
+ (!sym.declarations || !sym.declarations.find(ts.isGetAccessor)))) {
this.emitImplicitProperty(decl, declAnchor, vname);
}
@@ -2048,7 +2050,7 @@ class Visitor {
// If the class has a constructor, emit an entry for it.
const ctorSymbol = this.getCtorSymbol(decl);
- if (ctorSymbol) {
+ if (ctorSymbol && ctorSymbol.declarations) {
const ctorDecl = ctorSymbol.declarations[0];
const span = this.getTextSpan(ctorDecl, 'constructor');
const classCtorAnchor = this.newAnchor(ctorDecl, span.start, span.end);
@@ -2183,7 +2185,8 @@ class Visitor {
ts.getJSDocTags(node).find(tag => tag.tagName.text === 'deprecated');
if (deprecatedTag) {
this.emitFact(
- nodeVName, FactName.TAG_DEPRECATED, deprecatedTag.comment || '');
+ nodeVName, FactName.TAG_DEPRECATED,
+ (deprecatedTag.comment || '') as any);
}
}
