Skip to content

Commit 6d6c0ea

Browse files
committed
chore: check for nullability when accessing returnTypes
1 parent d9fba97 commit 6d6c0ea

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/compiler.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,10 +993,11 @@ export class Compiler extends DiagnosticEmitter {
993993
this.runtimeFeatures |= RuntimeFeatures.setArgumentsLength;
994994
signature = functionInstance.signature;
995995
}
996+
let signatureReturnTypes = signature.returnTypes;
996997
if (
997998
this.options.bindingsHint &&
998-
signature.returnTypes &&
999-
signature.returnTypes.length > 1
999+
signatureReturnTypes != null &&
1000+
signatureReturnTypes.length > 1
10001001
) {
10011002
this.error(
10021003
DiagnosticCode.Not_implemented_0,
@@ -2899,11 +2900,12 @@ export class Compiler extends DiagnosticEmitter {
28992900

29002901
let expr = this.compileExpression(expression, Type.auto);
29012902
if (!this.typesEqual(this.currentReturnTypes, returnTypes)) {
2903+
let currentReturnTypes = this.currentReturnTypes;
29022904
this.error(
29032905
DiagnosticCode.Type_0_is_not_assignable_to_type_1,
29042906
expression.range,
2905-
this.currentReturnTypes
2906-
? this.returnTypesToString(this.currentReturnTypes)
2907+
currentReturnTypes
2908+
? this.returnTypesToString(currentReturnTypes)
29072909
: this.currentType.toString(),
29082910
this.returnTypesToString(returnTypes)
29092911
);

0 commit comments

Comments
 (0)