@@ -1445,32 +1445,45 @@ export class ClassHelper {
14451445 }
14461446
14471447 private visitInputAndHostBinding ( property , inDecorator , sourceFile ?) {
1448- let inArgs = inDecorator . expression . arguments ;
1448+ const inArgs = inDecorator . expression . arguments ;
1449+
14491450 let _return : any = { } ;
14501451
1451- let getRequiredField = ( ) =>
1452+ let isInputConfigStringLiteral = false ;
1453+ let isInputConfigObjectLiteralExpression = false ;
1454+ let hasRequiredField = false ;
1455+ let hasAlias = false ;
1456+
1457+ const getRequiredField = ( ) =>
14521458 inArgs [ 0 ] . properties . find ( property => property . name . escapedText === 'required' ) ;
1453- let getAliasProperty = ( ) =>
1459+ const getAliasProperty = ( ) =>
14541460 inArgs [ 0 ] . properties . find ( property => property . name . escapedText === 'alias' ) ;
14551461
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+
14671480 _return . defaultValue = property . initializer
14681481 ? this . stringifyDefaultValue ( property . initializer )
14691482 : undefined ;
14701483 _return . deprecated = false ;
14711484 _return . deprecationMessage = '' ;
14721485
1473- if ( hasRequiredField ) {
1486+ if ( inArgs . length > 0 && inArgs [ 0 ] . properties && hasRequiredField ) {
14741487 _return . optional = getRequiredField ( ) . initializer . kind !== SyntaxKind . TrueKeyword ;
14751488 }
14761489
@@ -1509,9 +1522,9 @@ export class ClassHelper {
15091522 }
15101523 // Try to get inferred type
15111524 if ( property . symbol ) {
1512- let symbol : ts . Symbol = property . symbol ;
1525+ const symbol : ts . Symbol = property . symbol ;
15131526 if ( symbol . valueDeclaration ) {
1514- let symbolType = this . typeChecker . getTypeOfSymbolAtLocation (
1527+ const symbolType = this . typeChecker . getTypeOfSymbolAtLocation (
15151528 symbol ,
15161529 symbol . valueDeclaration
15171530 ) ;
0 commit comments