diff --git a/webapp/src/utils/readTypedMessages.ts b/webapp/src/utils/readTypedMessages.ts index c6c3bed8..f9e5cfe6 100644 --- a/webapp/src/utils/readTypedMessages.ts +++ b/webapp/src/utils/readTypedMessages.ts @@ -1,6 +1,6 @@ import ts from 'typescript'; -export default function readTypedMessages(fileName: string) { +export default function readTypedMessages(fileName: string): MessageData[] { const host = ts.createIncrementalCompilerHost( {}, { @@ -88,9 +88,8 @@ function inspectMessages(node: ts.CallExpression): MessageData[] { defaultMessage: argNode.text, id: id, params: - callNode.typeArguments?.map((typeArg) => { - const typeNode = typeArg as ts.TypeLiteralNode; - const memberNode = typeNode.members[0] as ts.PropertySignature; + (callNode.typeArguments?.[0] as ts.TypeLiteralNode)?.members.map((member) => { + const memberNode = member as ts.PropertySignature; const typeIdNode = memberNode.name as ts.Identifier; if (memberNode.type?.kind == ts.SyntaxKind.UnionType) { const unionNode = memberNode.type as ts.UnionTypeNode;