@@ -1445,32 +1445,45 @@ export class ClassHelper {
1445
1445
}
1446
1446
1447
1447
private visitInputAndHostBinding ( property , inDecorator , sourceFile ?) {
1448
- let inArgs = inDecorator . expression . arguments ;
1448
+ const inArgs = inDecorator . expression . arguments ;
1449
+
1449
1450
let _return : any = { } ;
1450
1451
1451
- let getRequiredField = ( ) =>
1452
+ let isInputConfigStringLiteral = false ;
1453
+ let isInputConfigObjectLiteralExpression = false ;
1454
+ let hasRequiredField = false ;
1455
+ let hasAlias = false ;
1456
+
1457
+ const getRequiredField = ( ) =>
1452
1458
inArgs [ 0 ] . properties . find ( property => property . name . escapedText === 'required' ) ;
1453
- let getAliasProperty = ( ) =>
1459
+ const getAliasProperty = ( ) =>
1454
1460
inArgs [ 0 ] . properties . find ( property => property . name . escapedText === 'alias' ) ;
1455
1461
1456
- let isInputConfigStringLiteral = inArgs [ 0 ] && ts . isStringLiteral ( inArgs [ 0 ] ) ;
1457
- let isInputConfigObjectLiteralExpression =
1458
- inArgs [ 0 ] && ts . isObjectLiteralExpression ( inArgs [ 0 ] ) ;
1459
- let hasRequiredField = isInputConfigObjectLiteralExpression && ! ! getRequiredField ( ) ;
1460
- let hasAlias = isInputConfigObjectLiteralExpression ? ! ! getAliasProperty ( ) : false ;
1461
-
1462
- _return . name = isInputConfigStringLiteral
1463
- ? inArgs [ 0 ] . text
1464
- : hasAlias
1465
- ? getAliasProperty ( ) . initializer . text
1466
- : property . name . text ;
1462
+ if ( inArgs . length > 0 && inArgs [ 0 ] . properties ) {
1463
+ isInputConfigStringLiteral = inArgs [ 0 ] && ts . isStringLiteral ( inArgs [ 0 ] ) ;
1464
+ isInputConfigObjectLiteralExpression =
1465
+ inArgs [ 0 ] && ts . isObjectLiteralExpression ( inArgs [ 0 ] ) ;
1466
+ hasRequiredField = isInputConfigObjectLiteralExpression && ! ! getRequiredField ( ) ;
1467
+ hasAlias = isInputConfigObjectLiteralExpression ? ! ! getAliasProperty ( ) : false ;
1468
+
1469
+ _return . name = isInputConfigStringLiteral
1470
+ ? inArgs [ 0 ] . text
1471
+ : hasAlias
1472
+ ? getAliasProperty ( ) . initializer . text
1473
+ : property . name . text ;
1474
+
1475
+ _return . required = ! ! getRequiredField ( ) ;
1476
+ } else {
1477
+ _return . name = property . name . text ;
1478
+ }
1479
+
1467
1480
_return . defaultValue = property . initializer
1468
1481
? this . stringifyDefaultValue ( property . initializer )
1469
1482
: undefined ;
1470
1483
_return . deprecated = false ;
1471
1484
_return . deprecationMessage = '' ;
1472
1485
1473
- if ( hasRequiredField ) {
1486
+ if ( inArgs . length > 0 && inArgs [ 0 ] . properties && hasRequiredField ) {
1474
1487
_return . optional = getRequiredField ( ) . initializer . kind !== SyntaxKind . TrueKeyword ;
1475
1488
}
1476
1489
@@ -1509,9 +1522,9 @@ export class ClassHelper {
1509
1522
}
1510
1523
// Try to get inferred type
1511
1524
if ( property . symbol ) {
1512
- let symbol : ts . Symbol = property . symbol ;
1525
+ const symbol : ts . Symbol = property . symbol ;
1513
1526
if ( symbol . valueDeclaration ) {
1514
- let symbolType = this . typeChecker . getTypeOfSymbolAtLocation (
1527
+ const symbolType = this . typeChecker . getTypeOfSymbolAtLocation (
1515
1528
symbol ,
1516
1529
symbol . valueDeclaration
1517
1530
) ;
0 commit comments