From c35c73764fdb789d7309e907bed47f366ecc7191 Mon Sep 17 00:00:00 2001 From: Hooked74 Date: Mon, 11 Nov 2019 20:58:56 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A1hange=20the=20default=20value=20when=20ge?= =?UTF-8?q?tting=20literal=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parser.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/parser.ts b/src/parser.ts index c588397d..d92aa163 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -741,8 +741,6 @@ export class Parser { // Literal values switch (initializer.kind) { - case ts.SyntaxKind.PropertyAccessExpression: - return initializer.getText(); case ts.SyntaxKind.FalseKeyword: return this.savePropValueAsString ? 'false' : false; case ts.SyntaxKind.TrueKeyword: @@ -764,11 +762,14 @@ export class Parser { return (initializer as ts.Identifier).text === 'undefined' ? 'undefined' : null; + case ts.SyntaxKind.PropertyAccessExpression: case ts.SyntaxKind.ObjectLiteralExpression: - // return the source text for an object literal - return (initializer as ts.ObjectLiteralExpression).getText(); default: - return null; + try { + return initializer.getText(); + } catch(e) { + return null; + } } }