mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-13 06:20:23 -06:00
Fix get type from short-hand property assignment
This commit is contained in:
parent
8a779e1e85
commit
e9122b4d85
@ -1665,6 +1665,13 @@ module ts {
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
// If it is a short-hand property assignment; Use the type of the identifier
|
||||
if (declaration.kind === SyntaxKind.ShortHandPropertyAssignment) {
|
||||
var type = checkIdentifier(<Identifier>(declaration.name));
|
||||
return type
|
||||
}
|
||||
|
||||
// Rest parameters default to type any[], other parameters default to type any
|
||||
var type = declaration.flags & NodeFlags.Rest ? createArrayType(anyType) : anyType;
|
||||
checkImplicitAny(type);
|
||||
|
||||
@ -574,6 +574,7 @@ module ts {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.Property:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShortHandPropertyAssignment:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
|
||||
@ -1969,7 +1969,7 @@ module ts {
|
||||
/** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */
|
||||
function isNameOfPropertyAssignment(node: Node): boolean {
|
||||
return (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) &&
|
||||
node.parent.kind === SyntaxKind.PropertyAssignment && (<PropertyDeclaration>node.parent).name === node;
|
||||
(node.parent.kind === SyntaxKind.PropertyAssignment || node.parent.kind === SyntaxKind.ShortHandPropertyAssignment) && (<PropertyDeclaration>node.parent).name === node;
|
||||
}
|
||||
|
||||
function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean {
|
||||
@ -2648,7 +2648,7 @@ module ts {
|
||||
|
||||
var existingMemberNames: Map<boolean> = {};
|
||||
forEach(existingMembers, m => {
|
||||
if (m.kind !== SyntaxKind.PropertyAssignment) {
|
||||
if (m.kind !== SyntaxKind.PropertyAssignment && m.kind !== SyntaxKind.ShortHandPropertyAssignment) {
|
||||
// Ignore omitted expressions for missing members in the object literal
|
||||
return;
|
||||
}
|
||||
@ -4569,6 +4569,7 @@ module ts {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.Property:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShortHandPropertyAssignment:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.Constructor:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user