From 7c926ecfd0b33235ba0503b011f5e6a7b3f7d841 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Tue, 11 Oct 2022 16:25:08 +1300 Subject: [PATCH] fix: check if modifiersType is undefined before passing it --- util/type.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/type.ts b/util/type.ts index 65cb3c1..bbd1ca1 100644 --- a/util/type.ts +++ b/util/type.ts @@ -286,7 +286,10 @@ function isReadonlyPropertyFromMappedType(type: ts.Type, name: ts.__String, chec // well-known symbols are not affected by mapped types if (declaration.readonlyToken !== undefined && !/^__@[^@]+$/.test(name)) return declaration.readonlyToken.kind !== ts.SyntaxKind.MinusToken; - return isPropertyReadonlyInType((<{modifiersType: ts.Type}>type).modifiersType, name, checker); + const modifiersType = (<{ modifiersType: ts.Type }>type).modifiersType; + if (modifiersType === undefined) + return false; + return isPropertyReadonlyInType(modifiersType, name, checker); } export function symbolHasReadonlyDeclaration(symbol: ts.Symbol, checker: ts.TypeChecker) {