From 7f58d79b0a445434e487d6b61bb14933fbe0c329 Mon Sep 17 00:00:00 2001 From: Zack Slayton Date: Fri, 14 Feb 2020 17:50:40 -0500 Subject: [PATCH 1/2] Avoid iterating over undefined array. --- src/lib/converter/nodes/class.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/converter/nodes/class.ts b/src/lib/converter/nodes/class.ts index 90d05d1e2..ef93fc945 100644 --- a/src/lib/converter/nodes/class.ts +++ b/src/lib/converter/nodes/class.ts @@ -69,7 +69,9 @@ export class ClassConverter extends ConverterNodeComponent const typesToInheritFrom: ts.Type[] = type.isIntersection() ? type.types : [ type ]; typesToInheritFrom.forEach((typeToInheritFrom: ts.Type) => { - typeToInheritFrom.symbol && typeToInheritFrom.symbol.declarations.forEach((declaration) => { + typeToInheritFrom.symbol + && typeToInheritFrom.symbol.declarations + && typeToInheritFrom.symbol.declarations.forEach((declaration) => { context.inherit(declaration, baseType.typeArguments); }); }); From 099bf20258b7e41aa896392315ba9c41304d4be6 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Sat, 15 Feb 2020 16:45:36 -0700 Subject: [PATCH 2/2] chore: Fix lint + add note about TS weirdness --- src/lib/converter/nodes/class.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/converter/nodes/class.ts b/src/lib/converter/nodes/class.ts index ef93fc945..7eef8d667 100644 --- a/src/lib/converter/nodes/class.ts +++ b/src/lib/converter/nodes/class.ts @@ -69,9 +69,12 @@ export class ClassConverter extends ConverterNodeComponent const typesToInheritFrom: ts.Type[] = type.isIntersection() ? type.types : [ type ]; typesToInheritFrom.forEach((typeToInheritFrom: ts.Type) => { - typeToInheritFrom.symbol - && typeToInheritFrom.symbol.declarations - && typeToInheritFrom.symbol.declarations.forEach((declaration) => { + // TODO: The TS declaration file claims that: + // 1. type.symbol is non-nullable + // 2. symbol.declarations is non-nullable + // These are both incorrect, GH#1207 for #2 and existing tests for #1. + // Figure out why this is the case and document. + typeToInheritFrom.symbol?.declarations?.forEach((declaration) => { context.inherit(declaration, baseType.typeArguments); }); });