From 13aff17975e5bcb94fa7e00a0e3e26789ef9d2dc Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 3 May 2016 17:08:06 -0700 Subject: [PATCH 1/6] Fix #8415: Add method declaration to contextually typed locations when searching for symbols --- src/services/services.ts | 13 +++++- .../renameContextuallyTypedProperties.ts | 43 +++++++++++++++++++ .../renameContextuallyTypedProperties2.ts | 43 +++++++++++++++++++ 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/renameContextuallyTypedProperties.ts create mode 100644 tests/cases/fourslash/renameContextuallyTypedProperties2.ts diff --git a/src/services/services.ts b/src/services/services.ts index 8d28d5d958a73..109ad7bd14f5c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2583,8 +2583,17 @@ namespace 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 || node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) && (node.parent).name === node; + if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) { + switch (node.parent.kind) { + case SyntaxKind.PropertyAssignment: + case SyntaxKind.ShorthandPropertyAssignment: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return (node.parent).name === node; + } + } + return false; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean { diff --git a/tests/cases/fourslash/renameContextuallyTypedProperties.ts b/tests/cases/fourslash/renameContextuallyTypedProperties.ts new file mode 100644 index 0000000000000..21885874269fd --- /dev/null +++ b/tests/cases/fourslash/renameContextuallyTypedProperties.ts @@ -0,0 +1,43 @@ +/// + +////interface I { +//// [|prop1|]: () => void; +//// prop2(): void; +////} +//// +////var o1: I = { +//// [|prop1|]() { }, +//// prop2() { } +////}; +//// +////var o2: I = { +//// [|prop1|]: () => { }, +//// prop2: () => { } +////}; +//// +////var o3: I = { +//// get [|prop1|]() { return () => { }; }, +//// get prop2() { return () => { }; } +////}; +//// +////var o4: I = { +//// set [|prop1|](v) { }, +//// set prop2(v) { } +////}; +//// +////var o5: I = { +//// "[|prop1|]"() { }, +//// "prop2"() { } +////}; +//// +////var o6: I = { +//// "[|prop1|]": function () { }, +//// "prop2": function () { } +////}; + +let ranges = test.ranges() +for (let range of ranges) { + goTo.file(range.fileName); + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} diff --git a/tests/cases/fourslash/renameContextuallyTypedProperties2.ts b/tests/cases/fourslash/renameContextuallyTypedProperties2.ts new file mode 100644 index 0000000000000..9961c9b8403fa --- /dev/null +++ b/tests/cases/fourslash/renameContextuallyTypedProperties2.ts @@ -0,0 +1,43 @@ +/// + +////interface I { +//// prop1: () => void; +//// [|prop2|](): void; +////} +//// +////var o1: I = { +//// prop1() { }, +//// [|prop2|]() { } +////}; +//// +////var o2: I = { +//// prop1: () => { }, +//// [|prop2|]: () => { } +////}; +//// +////var o3: I = { +//// get prop1() { return () => { }; }, +//// get [|prop2|]() { return () => { }; } +////}; +//// +////var o4: I = { +//// set prop1(v) { }, +//// set [|prop2|](v) { } +////}; +//// +////var o5: I = { +//// "prop1"() { }, +//// "[|prop2|]"() { } +////}; +//// +////var o6: I = { +//// "prop1": function () { }, +//// "[|prop2|]": function () { } +////}; + +let ranges = test.ranges() +for (let range of ranges) { + goTo.file(range.fileName); + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} From baa56290edc1cf26741917393bc7c4c1167d1631 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 3 May 2016 22:40:40 -0700 Subject: [PATCH 2/6] Enable find all refs and rename for computed property names with literal expressions --- src/compiler/checker.ts | 3 + src/compiler/utilities.ts | 10 ++ src/services/services.ts | 117 +++++++++++------- src/services/utilities.ts | 4 + .../findAllRefsForComputedProperties.ts | 24 ++++ .../findAllRefsForComputedProperties2.ts | 23 ++++ .../renameContextuallyTypedProperties.ts | 20 +++ .../renameContextuallyTypedProperties2.ts | 20 +++ 8 files changed, 177 insertions(+), 44 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsForComputedProperties.ts create mode 100644 tests/cases/fourslash/findAllRefsForComputedProperties2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index df3528a17ac3c..69a07700b3c55 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16555,6 +16555,9 @@ namespace ts { // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } + else if (isLiteralComputedPropertyDeclarationName(node)) { + return getSymbolOfNode(node.parent.parent); + } if (node.kind === SyntaxKind.Identifier) { if (isInRightSideOfImportOrExportAssignment(node)) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b6c681e5f03bb..d31419e7e81a6 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1564,6 +1564,13 @@ namespace ts { return false; } + export function isLiteralComputedPropertyDeclarationName(node: Node) { + return (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) && + node.parent.kind === SyntaxKind.ComputedPropertyName && + (node.parent).expression === node && + isDeclaration(node.parent.parent); + } + // Return true if the given identifier is classified as an IdentifierName export function isIdentifierName(node: Identifier): boolean { let parent = node.parent; @@ -1749,6 +1756,9 @@ namespace ts { const rightHandSideName = (nameExpression).name.text; return getPropertyNameForKnownSymbolName(rightHandSideName); } + else if (nameExpression.kind === SyntaxKind.StringLiteral || nameExpression.kind === SyntaxKind.NumericLiteral) { + return (nameExpression).text; + } } return undefined; diff --git a/src/services/services.ts b/src/services/services.ts index 109ad7bd14f5c..e4f41aff60bb0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2581,21 +2581,35 @@ namespace ts { isFunctionLike(node.parent) && (node.parent).name === node; } - /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ - function isNameOfPropertyAssignment(node: Node): boolean { - if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) { - switch (node.parent.kind) { - case SyntaxKind.PropertyAssignment: - case SyntaxKind.ShorthandPropertyAssignment: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - return (node.parent).name === node; - } + function isObjectLiteralPropertyDeclaration(node: Node): node is ObjectLiteralElement { + switch (node.kind) { + case SyntaxKind.PropertyAssignment: + case SyntaxKind.ShorthandPropertyAssignment: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return true; } return false; } + /** + * Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 } + */ + function getContainingObjectLiteralElement(node: Node): ObjectLiteralElement { + switch (node.kind) { + case SyntaxKind.StringLiteral: + case SyntaxKind.NumericLiteral: + if (node.parent.kind === SyntaxKind.ComputedPropertyName) { + return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; + } + // intential fall through + case SyntaxKind.Identifier: + return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; + } + return undefined; + } + function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean { if (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) { switch (node.parent.kind) { @@ -2611,6 +2625,8 @@ namespace ts { return (node.parent).name === node; case SyntaxKind.ElementAccessExpression: return (node.parent).argumentExpression === node; + case SyntaxKind.ComputedPropertyName: + return true; } } @@ -6217,7 +6233,8 @@ namespace ts { // If the location is name of property symbol from object literal destructuring pattern // Search the property symbol // for ( { property: p2 } of elems) { } - if (isNameOfPropertyAssignment(location) && location.parent.kind !== SyntaxKind.ShorthandPropertyAssignment) { + const containingObjectLiteralElement = getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== SyntaxKind.ShorthandPropertyAssignment) { const propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -6243,8 +6260,8 @@ namespace ts { // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set - if (isNameOfPropertyAssignment(location)) { - forEach(getPropertySymbolsFromContextualType(location), contextualSymbol => { + if (containingObjectLiteralElement) { + forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => { addRange(result, typeChecker.getRootSymbols(contextualSymbol)); }); @@ -6371,8 +6388,9 @@ namespace ts { // If the reference location is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol - if (isNameOfPropertyAssignment(referenceLocation)) { - const contextualSymbol = forEach(getPropertySymbolsFromContextualType(referenceLocation), contextualSymbol => { + const containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + const contextualSymbol = forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), contextualSymbol => { return forEach(typeChecker.getRootSymbols(contextualSymbol), s => searchSymbols.indexOf(s) >= 0 ? s : undefined); }); @@ -6418,35 +6436,45 @@ namespace ts { }); } - function getPropertySymbolsFromContextualType(node: Node): Symbol[] { - if (isNameOfPropertyAssignment(node)) { - const objectLiteral = node.parent.parent; - const contextualType = typeChecker.getContextualType(objectLiteral); - const name = (node).text; - if (contextualType) { - if (contextualType.flags & TypeFlags.Union) { - // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) - // if not, search the constituent types for the property - const unionProperty = contextualType.getProperty(name); - if (unionProperty) { - return [unionProperty]; - } - else { - const result: Symbol[] = []; - forEach((contextualType).types, t => { - const symbol = t.getProperty(name); - if (symbol) { - result.push(symbol); - } - }); - return result; - } + function getNameFromObjectLiteralElement(node: ObjectLiteralElement) { + if (node.name.kind === SyntaxKind.ComputedPropertyName) { + const nameExpression = (node.name).expression; + // treat computed property names where expression is string/numeric literal as just string/numeric literal + if (isStringOrNumericLiteral(nameExpression.kind)) { + return (nameExpression).text; + } + return undefined; + } + return (node.name).text; + } + + function getPropertySymbolsFromContextualType(node: ObjectLiteralElement): Symbol[] { + const objectLiteral = node.parent; + const contextualType = typeChecker.getContextualType(objectLiteral); + const name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + if (contextualType.flags & TypeFlags.Union) { + // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) + // if not, search the constituent types for the property + const unionProperty = contextualType.getProperty(name); + if (unionProperty) { + return [unionProperty]; } else { - const symbol = contextualType.getProperty(name); - if (symbol) { - return [symbol]; - } + const result: Symbol[] = []; + forEach((contextualType).types, t => { + const symbol = t.getProperty(name); + if (symbol) { + result.push(symbol); + } + }); + return result; + } + } + else { + const symbol = contextualType.getProperty(name); + if (symbol) { + return [symbol]; } } } @@ -7910,7 +7938,8 @@ namespace ts { // "a['propname']" then we want to store "propname" in the name table. if (isDeclarationName(node) || node.parent.kind === SyntaxKind.ExternalModuleReference || - isArgumentOfElementAccessExpression(node)) { + isArgumentOfElementAccessExpression(node) || + isLiteralComputedPropertyDeclarationName(node)) { nameTable[(node).text] = nameTable[(node).text] === undefined ? node.pos : -1; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 270c7d85d45bf..5a676a6692dde 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -821,6 +821,10 @@ namespace ts { if (isImportOrExportSpecifierName(location)) { return location.getText(); } + else if (isStringOrNumericLiteral(location.kind) && + location.parent.kind === SyntaxKind.ComputedPropertyName) { + return (location).text; + } // Try to get the local symbol if we're dealing with an 'export default' // since that symbol has the "true" name. diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties.ts b/tests/cases/fourslash/findAllRefsForComputedProperties.ts new file mode 100644 index 0000000000000..3ea226b3ce4ce --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForComputedProperties.ts @@ -0,0 +1,24 @@ +/// + + +////interface I { +//// ["[|prop1|]"]: () => void; +////} +//// +////class C implements I { +//// ["[|prop1|]"]: any; +////} +//// +////var x: I = { +//// ["[|prop1|]"]: function () { }, +////} + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts new file mode 100644 index 0000000000000..b9f6e9538eb83 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts @@ -0,0 +1,23 @@ +/// + +////interface I { +//// [[|42|]](): void; +////} +//// +////class C implements I { +//// [[|42|]]: any; +////} +//// +////var x: I = { +//// ["[|42|]"]: function () { } +////} + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameContextuallyTypedProperties.ts b/tests/cases/fourslash/renameContextuallyTypedProperties.ts index 21885874269fd..4feed49256fcc 100644 --- a/tests/cases/fourslash/renameContextuallyTypedProperties.ts +++ b/tests/cases/fourslash/renameContextuallyTypedProperties.ts @@ -34,6 +34,26 @@ //// "[|prop1|]": function () { }, //// "prop2": function () { } ////}; +//// +////var o7: I = { +//// ["[|prop1|]"]: function () { }, +//// ["prop2"]: function () { } +////}; +//// +////var o8: I = { +//// ["[|prop1|]"]() { }, +//// ["prop2"]() { } +////}; +//// +////var o9: I = { +//// get ["[|prop1|]"]() { return () => { }; }, +//// get ["prop2"]() { return () => { }; } +////}; +//// +////var o10: I = { +//// set ["[|prop1|]"](v) { }, +//// set ["prop2"](v) { } +////}; let ranges = test.ranges() for (let range of ranges) { diff --git a/tests/cases/fourslash/renameContextuallyTypedProperties2.ts b/tests/cases/fourslash/renameContextuallyTypedProperties2.ts index 9961c9b8403fa..1887c7751a558 100644 --- a/tests/cases/fourslash/renameContextuallyTypedProperties2.ts +++ b/tests/cases/fourslash/renameContextuallyTypedProperties2.ts @@ -34,6 +34,26 @@ //// "prop1": function () { }, //// "[|prop2|]": function () { } ////}; +//// +////var o7: I = { +//// ["prop1"]: function () { }, +//// ["[|prop2|]"]: function () { } +////}; +//// +////var o8: I = { +//// ["prop1"]() { }, +//// ["[|prop2|]"]() { } +////}; +//// +////var o9: I = { +//// get ["prop1"]() { return () => { }; }, +//// get ["[|prop2|]"]() { return () => { }; } +////}; +//// +////var o10: I = { +//// set ["prop1"](v) { }, +//// set ["[|prop2|]"](v) { } +////}; let ranges = test.ranges() for (let range of ranges) { From 1af576b0641e8dc96a36ee9d164147e4407e475a Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 4 May 2016 12:06:51 -0700 Subject: [PATCH 3/6] Fix #4808: Follow target symbols --- src/compiler/checker.ts | 6 +++++- .../findAllRefsForObjectLiteralProperties.ts | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 786d73dd06c54..a7d862fb67302 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16795,7 +16795,11 @@ namespace ts { return symbols; } else if (symbol.flags & SymbolFlags.Transient) { - const target = getSymbolLinks(symbol).target; + let target: Symbol; + let next: Symbol = symbol; + while (next = getSymbolLinks(next).target) { + target = next; + } if (target) { return [target]; } diff --git a/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts b/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts new file mode 100644 index 0000000000000..cb5e702dc9068 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts @@ -0,0 +1,20 @@ +/// + +////var x = { +//// [|property|]: {} +////}; +//// +////x.[|property|]; +//// +////let {[|property|]: pVar} = x; + + +let ranges = test.ranges(); +for (let range of ranges) { + goTo.position(range.start); + + verify.referencesCountIs(ranges.length); + for (let expectedReference of ranges) { + verify.referencesAtPositionContains(expectedReference); + } +} \ No newline at end of file From c12f1902a02deacb4c0909427117e462b456cad6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 4 May 2016 14:05:50 -0700 Subject: [PATCH 4/6] Accept symbol baselines --- .../reference/computedPropertyNames10_ES5.symbols | 4 ++++ .../reference/computedPropertyNames10_ES6.symbols | 4 ++++ .../reference/computedPropertyNames11_ES5.symbols | 3 +++ .../reference/computedPropertyNames11_ES6.symbols | 3 +++ .../reference/computedPropertyNames13_ES5.symbols | 4 ++++ .../reference/computedPropertyNames13_ES6.symbols | 4 ++++ .../reference/computedPropertyNames16_ES5.symbols | 3 +++ .../reference/computedPropertyNames16_ES6.symbols | 3 +++ .../reference/computedPropertyNames37_ES5.symbols | 2 ++ .../reference/computedPropertyNames37_ES6.symbols | 2 ++ .../reference/computedPropertyNames41_ES5.symbols | 1 + .../reference/computedPropertyNames41_ES6.symbols | 1 + .../reference/computedPropertyNames4_ES5.symbols | 4 ++++ .../reference/computedPropertyNames4_ES6.symbols | 4 ++++ .../computedPropertyNamesSourceMap1_ES5.symbols | 2 ++ .../computedPropertyNamesSourceMap1_ES6.symbols | 2 ++ .../computedPropertyNamesSourceMap2_ES5.symbols | 2 ++ .../computedPropertyNamesSourceMap2_ES6.symbols | 2 ++ .../contextuallyTypedBindingInitializer.symbols | 1 + .../baselines/reference/decoratorOnClassMethod13.symbols | 2 ++ .../baselines/reference/decoratorOnClassMethod4.symbols | 1 + .../baselines/reference/decoratorOnClassMethod5.symbols | 1 + .../baselines/reference/decoratorOnClassMethod7.symbols | 1 + .../emitClassDeclarationWithGetterSetterInES6.symbols | 9 +++++++++ .../emitClassDeclarationWithMethodInES6.symbols | 8 ++++++++ tests/baselines/reference/exportEqualsAmd.symbols | 3 ++- tests/baselines/reference/exportEqualsCommonJs.symbols | 3 ++- tests/baselines/reference/exportEqualsUmd.symbols | 3 ++- 28 files changed, 79 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.symbols b/tests/baselines/reference/computedPropertyNames10_ES5.symbols index 17d1f7ca11757..7f872b2abf053 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames10_ES5.symbols @@ -29,7 +29,11 @@ var v = { >s : Symbol(s, Decl(computedPropertyNames10_ES5.ts, 0, 3)) [""]() { }, +>"" : Symbol([""], Decl(computedPropertyNames10_ES5.ts, 8, 15)) + [0]() { }, +>0 : Symbol([0], Decl(computedPropertyNames10_ES5.ts, 9, 15)) + [a]() { }, >a : Symbol(a, Decl(computedPropertyNames10_ES5.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames10_ES6.symbols b/tests/baselines/reference/computedPropertyNames10_ES6.symbols index 4141b7872089c..5912c3f694174 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames10_ES6.symbols @@ -29,7 +29,11 @@ var v = { >s : Symbol(s, Decl(computedPropertyNames10_ES6.ts, 0, 3)) [""]() { }, +>"" : Symbol([""], Decl(computedPropertyNames10_ES6.ts, 8, 15)) + [0]() { }, +>0 : Symbol([0], Decl(computedPropertyNames10_ES6.ts, 9, 15)) + [a]() { }, >a : Symbol(a, Decl(computedPropertyNames10_ES6.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.symbols b/tests/baselines/reference/computedPropertyNames11_ES5.symbols index 34326273e595a..f508047a8648e 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames11_ES5.symbols @@ -31,9 +31,12 @@ var v = { >s : Symbol(s, Decl(computedPropertyNames11_ES5.ts, 0, 3)) set [""](v) { }, +>"" : Symbol([""], Decl(computedPropertyNames11_ES5.ts, 8, 29)) >v : Symbol(v, Decl(computedPropertyNames11_ES5.ts, 9, 13)) get [0]() { return 0; }, +>0 : Symbol([0], Decl(computedPropertyNames11_ES5.ts, 9, 20)) + set [a](v) { }, >a : Symbol(a, Decl(computedPropertyNames11_ES5.ts, 2, 3)) >v : Symbol(v, Decl(computedPropertyNames11_ES5.ts, 11, 12)) diff --git a/tests/baselines/reference/computedPropertyNames11_ES6.symbols b/tests/baselines/reference/computedPropertyNames11_ES6.symbols index 73503eb2758eb..8ffce9989c032 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames11_ES6.symbols @@ -31,9 +31,12 @@ var v = { >s : Symbol(s, Decl(computedPropertyNames11_ES6.ts, 0, 3)) set [""](v) { }, +>"" : Symbol([""], Decl(computedPropertyNames11_ES6.ts, 8, 29)) >v : Symbol(v, Decl(computedPropertyNames11_ES6.ts, 9, 13)) get [0]() { return 0; }, +>0 : Symbol([0], Decl(computedPropertyNames11_ES6.ts, 9, 20)) + set [a](v) { }, >a : Symbol(a, Decl(computedPropertyNames11_ES6.ts, 2, 3)) >v : Symbol(v, Decl(computedPropertyNames11_ES6.ts, 11, 12)) diff --git a/tests/baselines/reference/computedPropertyNames13_ES5.symbols b/tests/baselines/reference/computedPropertyNames13_ES5.symbols index ea2e1b025e57b..493ea44b3399d 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames13_ES5.symbols @@ -29,7 +29,11 @@ class C { >s : Symbol(s, Decl(computedPropertyNames13_ES5.ts, 0, 3)) static [""]() { } +>"" : Symbol(C[[""]], Decl(computedPropertyNames13_ES5.ts, 8, 14)) + [0]() { } +>0 : Symbol(C[[0]], Decl(computedPropertyNames13_ES5.ts, 9, 21)) + [a]() { } >a : Symbol(a, Decl(computedPropertyNames13_ES5.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames13_ES6.symbols b/tests/baselines/reference/computedPropertyNames13_ES6.symbols index 21f7700acef41..7c421d3f9f77c 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames13_ES6.symbols @@ -29,7 +29,11 @@ class C { >s : Symbol(s, Decl(computedPropertyNames13_ES6.ts, 0, 3)) static [""]() { } +>"" : Symbol(C[[""]], Decl(computedPropertyNames13_ES6.ts, 8, 14)) + [0]() { } +>0 : Symbol(C[[0]], Decl(computedPropertyNames13_ES6.ts, 9, 21)) + [a]() { } >a : Symbol(a, Decl(computedPropertyNames13_ES6.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames16_ES5.symbols b/tests/baselines/reference/computedPropertyNames16_ES5.symbols index 62450e0aa4ab4..43f6e208957f7 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames16_ES5.symbols @@ -31,9 +31,12 @@ class C { >s : Symbol(s, Decl(computedPropertyNames16_ES5.ts, 0, 3)) static set [""](v) { } +>"" : Symbol(C[[""]], Decl(computedPropertyNames16_ES5.ts, 8, 28)) >v : Symbol(v, Decl(computedPropertyNames16_ES5.ts, 9, 20)) get [0]() { return 0; } +>0 : Symbol(C[[0]], Decl(computedPropertyNames16_ES5.ts, 9, 26)) + set [a](v) { } >a : Symbol(a, Decl(computedPropertyNames16_ES5.ts, 2, 3)) >v : Symbol(v, Decl(computedPropertyNames16_ES5.ts, 11, 12)) diff --git a/tests/baselines/reference/computedPropertyNames16_ES6.symbols b/tests/baselines/reference/computedPropertyNames16_ES6.symbols index dc241f67547a5..4febdc01b9b7f 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames16_ES6.symbols @@ -31,9 +31,12 @@ class C { >s : Symbol(s, Decl(computedPropertyNames16_ES6.ts, 0, 3)) static set [""](v) { } +>"" : Symbol(C[[""]], Decl(computedPropertyNames16_ES6.ts, 8, 28)) >v : Symbol(v, Decl(computedPropertyNames16_ES6.ts, 9, 20)) get [0]() { return 0; } +>0 : Symbol(C[[0]], Decl(computedPropertyNames16_ES6.ts, 9, 26)) + set [a](v) { } >a : Symbol(a, Decl(computedPropertyNames16_ES6.ts, 2, 3)) >v : Symbol(v, Decl(computedPropertyNames16_ES6.ts, 11, 12)) diff --git a/tests/baselines/reference/computedPropertyNames37_ES5.symbols b/tests/baselines/reference/computedPropertyNames37_ES5.symbols index 62e92ee6efcd9..7763c5970a35f 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames37_ES5.symbols @@ -17,9 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } +>"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames37_ES5.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames37_ES5.ts, 0, 0)) set ["set1"](p: Foo2) { } +>"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames37_ES5.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames37_ES5.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames37_ES5.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames37_ES6.symbols b/tests/baselines/reference/computedPropertyNames37_ES6.symbols index 7221614581a3c..d2e1e2fdc6e69 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames37_ES6.symbols @@ -17,9 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } +>"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames37_ES6.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames37_ES6.ts, 0, 0)) set ["set1"](p: Foo2) { } +>"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames37_ES6.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames37_ES6.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames37_ES6.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames41_ES5.symbols b/tests/baselines/reference/computedPropertyNames41_ES5.symbols index 3db1cf16a2b6e..821a39c8d594f 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames41_ES5.symbols @@ -17,5 +17,6 @@ class C { // Computed properties static [""]() { return new Foo } +>"" : Symbol(C[[""]], Decl(computedPropertyNames41_ES5.ts, 4, 28)) >Foo : Symbol(Foo, Decl(computedPropertyNames41_ES5.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames41_ES6.symbols b/tests/baselines/reference/computedPropertyNames41_ES6.symbols index bedbf7953f7c2..a075603e252c7 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames41_ES6.symbols @@ -17,5 +17,6 @@ class C { // Computed properties static [""]() { return new Foo } +>"" : Symbol(C[[""]], Decl(computedPropertyNames41_ES6.ts, 4, 28)) >Foo : Symbol(Foo, Decl(computedPropertyNames41_ES6.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.symbols b/tests/baselines/reference/computedPropertyNames4_ES5.symbols index be2014862864c..e49e333d7385e 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames4_ES5.symbols @@ -31,7 +31,11 @@ var v = { >s : Symbol(s, Decl(computedPropertyNames4_ES5.ts, 0, 3)) [""]: 0, +>"" : Symbol([""], Decl(computedPropertyNames4_ES5.ts, 8, 12)) + [0]: 0, +>0 : Symbol([0], Decl(computedPropertyNames4_ES5.ts, 9, 12)) + [a]: 1, >a : Symbol(a, Decl(computedPropertyNames4_ES5.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames4_ES6.symbols b/tests/baselines/reference/computedPropertyNames4_ES6.symbols index b531a1b3d2844..345cdb1ad3ed5 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames4_ES6.symbols @@ -31,7 +31,11 @@ var v = { >s : Symbol(s, Decl(computedPropertyNames4_ES6.ts, 0, 3)) [""]: 0, +>"" : Symbol([""], Decl(computedPropertyNames4_ES6.ts, 8, 12)) + [0]: 0, +>0 : Symbol([0], Decl(computedPropertyNames4_ES6.ts, 9, 12)) + [a]: 1, >a : Symbol(a, Decl(computedPropertyNames4_ES6.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols index 89463c12c4485..f127b919b01bb 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols @@ -3,6 +3,8 @@ class C { >C : Symbol(C, Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 0)) ["hello"]() { +>"hello" : Symbol(C[["hello"]], Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 9)) + debugger; } } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols index 45d2acb2b102f..c8bdcc6883553 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols @@ -3,6 +3,8 @@ class C { >C : Symbol(C, Decl(computedPropertyNamesSourceMap1_ES6.ts, 0, 0)) ["hello"]() { +>"hello" : Symbol(C[["hello"]], Decl(computedPropertyNamesSourceMap1_ES6.ts, 0, 9)) + debugger; } } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.symbols b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.symbols index b9a389da6360a..5e159065410a8 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.symbols @@ -3,6 +3,8 @@ var v = { >v : Symbol(v, Decl(computedPropertyNamesSourceMap2_ES5.ts, 0, 3)) ["hello"]() { +>"hello" : Symbol(["hello"], Decl(computedPropertyNamesSourceMap2_ES5.ts, 0, 9)) + debugger; } } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES6.symbols b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES6.symbols index 6c9d1e1d5fd34..e2985711b83b3 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES6.symbols @@ -3,6 +3,8 @@ var v = { >v : Symbol(v, Decl(computedPropertyNamesSourceMap2_ES6.ts, 0, 3)) ["hello"]() { +>"hello" : Symbol(["hello"], Decl(computedPropertyNamesSourceMap2_ES6.ts, 0, 9)) + debugger; } } diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols b/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols index 8a3b4cc79c22f..67406172e7a2f 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols @@ -26,6 +26,7 @@ function f2({ "show": showRename = v => v.toString() }: Show) {} function f3({ ["show"]: showRename = v => v.toString() }: Show) {} >f3 : Symbol(f3, Decl(contextuallyTypedBindingInitializer.ts, 4, 64)) +>"show" : Symbol(showRename, Decl(contextuallyTypedBindingInitializer.ts, 5, 13)) >showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializer.ts, 5, 13)) >v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 5, 36)) >v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/decoratorOnClassMethod13.symbols b/tests/baselines/reference/decoratorOnClassMethod13.symbols index 389b45e5679a6..7cd369be14421 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod13.symbols @@ -15,7 +15,9 @@ class C { @dec ["1"]() { } >dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0)) +>"1" : Symbol(C[["1"]], Decl(decoratorOnClassMethod13.ts, 2, 9)) @dec ["b"]() { } >dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0)) +>"b" : Symbol(C[["b"]], Decl(decoratorOnClassMethod13.ts, 3, 20)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod4.symbols b/tests/baselines/reference/decoratorOnClassMethod4.symbols index 909fcd7f42456..da0e9eafca7f6 100644 --- a/tests/baselines/reference/decoratorOnClassMethod4.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod4.symbols @@ -15,4 +15,5 @@ class C { @dec ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod4.ts, 0, 0)) +>"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod4.ts, 2, 9)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod5.symbols b/tests/baselines/reference/decoratorOnClassMethod5.symbols index a9780c1efa41b..bd895deeea808 100644 --- a/tests/baselines/reference/decoratorOnClassMethod5.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod5.symbols @@ -15,4 +15,5 @@ class C { @dec() ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod5.ts, 0, 0)) +>"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod5.ts, 2, 9)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod7.symbols b/tests/baselines/reference/decoratorOnClassMethod7.symbols index 3837816f79bd4..9ec0de0c205f9 100644 --- a/tests/baselines/reference/decoratorOnClassMethod7.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod7.symbols @@ -15,4 +15,5 @@ class C { @dec public ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod7.ts, 0, 0)) +>"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod7.ts, 2, 9)) } diff --git a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols index c48cc1d6f85c3..89c49123e7757 100644 --- a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols +++ b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols @@ -19,19 +19,27 @@ class C { return "BYE"; } static get ["computedname"]() { +>"computedname" : Symbol(C[["computedname"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) + return ""; } get ["computedname1"]() { +>"computedname1" : Symbol(C[["computedname1"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 10, 5)) + return ""; } get ["computedname2"]() { +>"computedname2" : Symbol(C[["computedname2"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 13, 5)) + return ""; } set ["computedname3"](x: any) { +>"computedname3" : Symbol(C[["computedname3"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 16, 5)) >x : Symbol(x, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 18, 26)) } set ["computedname4"](y: string) { +>"computedname4" : Symbol(C[["computedname4"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 19, 5)) >y : Symbol(y, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 20, 26)) } @@ -44,5 +52,6 @@ class C { >b : Symbol(b, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 19)) static set ["computedname"](b: string) { } +>"computedname" : Symbol(C[["computedname"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) >b : Symbol(b, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 25, 32)) } diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols index 45990c6e6288f..54522c5834ad0 100644 --- a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols @@ -9,10 +9,14 @@ class D { >foo : Symbol(D.foo, Decl(emitClassDeclarationWithMethodInES6.ts, 1, 17)) ["computedName1"]() { } +>"computedName1" : Symbol(D[["computedName1"]], Decl(emitClassDeclarationWithMethodInES6.ts, 2, 13)) + ["computedName2"](a: string) { } +>"computedName2" : Symbol(D[["computedName2"]], Decl(emitClassDeclarationWithMethodInES6.ts, 3, 27)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 4, 22)) ["computedName3"](a: string): number { return 1; } +>"computedName3" : Symbol(D[["computedName3"]], Decl(emitClassDeclarationWithMethodInES6.ts, 4, 36)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 5, 22)) bar(): string { @@ -31,10 +35,14 @@ class D { return "HELLO"; } static ["computedname4"]() { } +>"computedname4" : Symbol(D[["computedname4"]], Decl(emitClassDeclarationWithMethodInES6.ts, 11, 5)) + static ["computedname5"](a: string) { } +>"computedname5" : Symbol(D[["computedname5"]], Decl(emitClassDeclarationWithMethodInES6.ts, 12, 34)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 13, 29)) static ["computedname6"](a: string): boolean { return true; } +>"computedname6" : Symbol(D[["computedname6"]], Decl(emitClassDeclarationWithMethodInES6.ts, 13, 43)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 14, 29)) static staticMethod() { diff --git a/tests/baselines/reference/exportEqualsAmd.symbols b/tests/baselines/reference/exportEqualsAmd.symbols index db087c5678627..0a35efe187f98 100644 --- a/tests/baselines/reference/exportEqualsAmd.symbols +++ b/tests/baselines/reference/exportEqualsAmd.symbols @@ -1,3 +1,4 @@ === tests/cases/compiler/exportEqualsAmd.ts === export = { ["hi"]: "there" }; -No type information for this code. \ No newline at end of file +>"hi" : Symbol(["hi"], Decl(exportEqualsAmd.ts, 0, 10)) + diff --git a/tests/baselines/reference/exportEqualsCommonJs.symbols b/tests/baselines/reference/exportEqualsCommonJs.symbols index 1c92a34bbc24b..ce82666336dbc 100644 --- a/tests/baselines/reference/exportEqualsCommonJs.symbols +++ b/tests/baselines/reference/exportEqualsCommonJs.symbols @@ -1,3 +1,4 @@ === tests/cases/compiler/exportEqualsCommonJs.ts === export = { ["hi"]: "there" }; -No type information for this code. \ No newline at end of file +>"hi" : Symbol(["hi"], Decl(exportEqualsCommonJs.ts, 0, 10)) + diff --git a/tests/baselines/reference/exportEqualsUmd.symbols b/tests/baselines/reference/exportEqualsUmd.symbols index 480b8389030e3..b6c669e31a3cb 100644 --- a/tests/baselines/reference/exportEqualsUmd.symbols +++ b/tests/baselines/reference/exportEqualsUmd.symbols @@ -1,3 +1,4 @@ === tests/cases/compiler/exportEqualsUmd.ts === export = { ["hi"]: "there" }; -No type information for this code. \ No newline at end of file +>"hi" : Symbol(["hi"], Decl(exportEqualsUmd.ts, 0, 10)) + From bf867cc24eb5be1ea52784e4cb2d80b4df2e8ab4 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 4 May 2016 14:09:35 -0700 Subject: [PATCH 5/6] accept emit baselines --- .../reference/computedPropertyNames11_ES5.js | 12 ++++++++++-- .../reference/computedPropertyNames16_ES5.js | 10 ++++++++++ .../reference/computedPropertyNames36_ES5.js | 4 ++++ .../reference/computedPropertyNames37_ES5.js | 4 ++++ .../reference/computedPropertyNames43_ES5.js | 4 ++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.js b/tests/baselines/reference/computedPropertyNames11_ES5.js index 0917f82477049..64c0b0bd67e35 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.js +++ b/tests/baselines/reference/computedPropertyNames11_ES5.js @@ -46,8 +46,16 @@ var v = (_a = {}, enumerable: true, configurable: true }), - , - , + Object.defineProperty(_a, "", { + set: function (v) { }, + enumerable: true, + configurable: true + }), + Object.defineProperty(_a, 0, { + get: function () { return 0; }, + enumerable: true, + configurable: true + }), Object.defineProperty(_a, a, { set: function (v) { }, enumerable: true, diff --git a/tests/baselines/reference/computedPropertyNames16_ES5.js b/tests/baselines/reference/computedPropertyNames16_ES5.js index 5d8471e6560a4..92b98ecb1baba 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES5.js +++ b/tests/baselines/reference/computedPropertyNames16_ES5.js @@ -48,6 +48,16 @@ var C = (function () { enumerable: true, configurable: true }); + Object.defineProperty(C, "", { + set: function (v) { }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, 0, { + get: function () { return 0; }, + enumerable: true, + configurable: true + }); Object.defineProperty(C.prototype, a, { set: function (v) { }, enumerable: true, diff --git a/tests/baselines/reference/computedPropertyNames36_ES5.js b/tests/baselines/reference/computedPropertyNames36_ES5.js index 884e425e25b20..ec5643db26a7f 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES5.js +++ b/tests/baselines/reference/computedPropertyNames36_ES5.js @@ -27,6 +27,10 @@ var C = (function () { Object.defineProperty(C.prototype, "get1", { // Computed properties get: function () { return new Foo; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "set1", { set: function (p) { }, enumerable: true, configurable: true diff --git a/tests/baselines/reference/computedPropertyNames37_ES5.js b/tests/baselines/reference/computedPropertyNames37_ES5.js index 8cdc0af30e729..914fd9a898e20 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES5.js +++ b/tests/baselines/reference/computedPropertyNames37_ES5.js @@ -27,6 +27,10 @@ var C = (function () { Object.defineProperty(C.prototype, "get1", { // Computed properties get: function () { return new Foo; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "set1", { set: function (p) { }, enumerable: true, configurable: true diff --git a/tests/baselines/reference/computedPropertyNames43_ES5.js b/tests/baselines/reference/computedPropertyNames43_ES5.js index 9690d0b8196bb..c79a4d8d6d10a 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES5.js +++ b/tests/baselines/reference/computedPropertyNames43_ES5.js @@ -41,6 +41,10 @@ var D = (function (_super) { Object.defineProperty(D.prototype, "get1", { // Computed properties get: function () { return new Foo; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(D.prototype, "set1", { set: function (p) { }, enumerable: true, configurable: true From 0de410627e1c2acafc0f73e97ec521a2c5befc2b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Sun, 8 May 2016 15:59:15 -0700 Subject: [PATCH 6/6] Code review comments --- src/compiler/checker.ts | 2 +- src/compiler/utilities.ts | 1 - src/services/services.ts | 35 +++++++++++++---------------------- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5a3bbaf9189d5..351a218f82c8c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16916,7 +16916,7 @@ namespace ts { } else if (symbol.flags & SymbolFlags.Transient) { let target: Symbol; - let next: Symbol = symbol; + let next = symbol; while (next = getSymbolLinks(next).target) { target = next; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f8b140c0ba0c5..208723159c2ab 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1568,7 +1568,6 @@ namespace ts { export function isLiteralComputedPropertyDeclarationName(node: Node) { return (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) && node.parent.kind === SyntaxKind.ComputedPropertyName && - (node.parent).expression === node && isDeclaration(node.parent.parent); } diff --git a/src/services/services.ts b/src/services/services.ts index fdf291c3280a8..8b89056abbada 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -6453,30 +6453,21 @@ namespace ts { const contextualType = typeChecker.getContextualType(objectLiteral); const name = getNameFromObjectLiteralElement(node); if (name && contextualType) { - if (contextualType.flags & TypeFlags.Union) { - // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) - // if not, search the constituent types for the property - const unionProperty = contextualType.getProperty(name); - if (unionProperty) { - return [unionProperty]; - } - else { - const result: Symbol[] = []; - forEach((contextualType).types, t => { - const symbol = t.getProperty(name); - if (symbol) { - result.push(symbol); - } - }); - return result; - } + const result: Symbol[] = []; + const symbol = contextualType.getProperty(name); + if (symbol) { + result.push(symbol); } - else { - const symbol = contextualType.getProperty(name); - if (symbol) { - return [symbol]; - } + + if (contextualType.flags & TypeFlags.Union) { + forEach((contextualType).types, t => { + const symbol = t.getProperty(name); + if (symbol) { + result.push(symbol); + } + }); } + return result; } return undefined; }