File tree 3 files changed +11
-2
lines changed
3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1665,6 +1665,13 @@ module ts {
1665
1665
}
1666
1666
return type ;
1667
1667
}
1668
+
1669
+ // If it is a short-hand property assignment; Use the type of the identifier
1670
+ if ( declaration . kind === SyntaxKind . ShortHandPropertyAssignment ) {
1671
+ var type = checkIdentifier ( < Identifier > ( declaration . name ) ) ;
1672
+ return type
1673
+ }
1674
+
1668
1675
// Rest parameters default to type any[], other parameters default to type any
1669
1676
var type = declaration . flags & NodeFlags . Rest ? createArrayType ( anyType ) : anyType ;
1670
1677
checkImplicitAny ( type ) ;
Original file line number Diff line number Diff line change @@ -574,6 +574,7 @@ module ts {
574
574
case SyntaxKind . VariableDeclaration :
575
575
case SyntaxKind . Property :
576
576
case SyntaxKind . PropertyAssignment :
577
+ case SyntaxKind . ShortHandPropertyAssignment :
577
578
case SyntaxKind . EnumMember :
578
579
case SyntaxKind . Method :
579
580
case SyntaxKind . FunctionDeclaration :
Original file line number Diff line number Diff line change @@ -1969,7 +1969,7 @@ module ts {
1969
1969
/** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */
1970
1970
function isNameOfPropertyAssignment ( node : Node ) : boolean {
1971
1971
return ( node . kind === SyntaxKind . Identifier || node . kind === SyntaxKind . StringLiteral || node . kind === SyntaxKind . NumericLiteral ) &&
1972
- node . parent . kind === SyntaxKind . PropertyAssignment && ( < PropertyDeclaration > node . parent ) . name === node ;
1972
+ ( node . parent . kind === SyntaxKind . PropertyAssignment || node . parent . kind === SyntaxKind . ShortHandPropertyAssignment ) && ( < PropertyDeclaration > node . parent ) . name === node ;
1973
1973
}
1974
1974
1975
1975
function isLiteralNameOfPropertyDeclarationOrIndexAccess ( node : Node ) : boolean {
@@ -2648,7 +2648,7 @@ module ts {
2648
2648
2649
2649
var existingMemberNames : Map < boolean > = { } ;
2650
2650
forEach ( existingMembers , m => {
2651
- if ( m . kind !== SyntaxKind . PropertyAssignment ) {
2651
+ if ( m . kind !== SyntaxKind . PropertyAssignment && m . kind !== SyntaxKind . ShortHandPropertyAssignment ) {
2652
2652
// Ignore omitted expressions for missing members in the object literal
2653
2653
return ;
2654
2654
}
@@ -4569,6 +4569,7 @@ module ts {
4569
4569
case SyntaxKind . VariableDeclaration :
4570
4570
case SyntaxKind . Property :
4571
4571
case SyntaxKind . PropertyAssignment :
4572
+ case SyntaxKind . ShortHandPropertyAssignment :
4572
4573
case SyntaxKind . EnumMember :
4573
4574
case SyntaxKind . Method :
4574
4575
case SyntaxKind . Constructor :
You can’t perform that action at this time.
0 commit comments