File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1665,6 +1665,13 @@ module ts {
16651665 }
16661666 return type ;
16671667 }
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+
16681675 // Rest parameters default to type any[], other parameters default to type any
16691676 var type = declaration . flags & NodeFlags . Rest ? createArrayType ( anyType ) : anyType ;
16701677 checkImplicitAny ( type ) ;
Original file line number Diff line number Diff line change @@ -574,6 +574,7 @@ module ts {
574574 case SyntaxKind . VariableDeclaration :
575575 case SyntaxKind . Property :
576576 case SyntaxKind . PropertyAssignment :
577+ case SyntaxKind . ShortHandPropertyAssignment :
577578 case SyntaxKind . EnumMember :
578579 case SyntaxKind . Method :
579580 case SyntaxKind . FunctionDeclaration :
Original file line number Diff line number Diff line change @@ -1969,7 +1969,7 @@ module ts {
19691969 /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */
19701970 function isNameOfPropertyAssignment ( node : Node ) : boolean {
19711971 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 ;
19731973 }
19741974
19751975 function isLiteralNameOfPropertyDeclarationOrIndexAccess ( node : Node ) : boolean {
@@ -2648,7 +2648,7 @@ module ts {
26482648
26492649 var existingMemberNames : Map < boolean > = { } ;
26502650 forEach ( existingMembers , m => {
2651- if ( m . kind !== SyntaxKind . PropertyAssignment ) {
2651+ if ( m . kind !== SyntaxKind . PropertyAssignment && m . kind !== SyntaxKind . ShortHandPropertyAssignment ) {
26522652 // Ignore omitted expressions for missing members in the object literal
26532653 return ;
26542654 }
@@ -4569,6 +4569,7 @@ module ts {
45694569 case SyntaxKind . VariableDeclaration :
45704570 case SyntaxKind . Property :
45714571 case SyntaxKind . PropertyAssignment :
4572+ case SyntaxKind . ShortHandPropertyAssignment :
45724573 case SyntaxKind . EnumMember :
45734574 case SyntaxKind . Method :
45744575 case SyntaxKind . Constructor :
You can’t perform that action at this time.
0 commit comments