mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #8456 from Microsoft/Fix8415
Fix #8415: consider accessors when searching for contextually typed properties
This commit is contained in:
@@ -16688,6 +16688,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(<Identifier>node)) {
|
||||
@@ -16919,7 +16922,11 @@ namespace ts {
|
||||
return symbols;
|
||||
}
|
||||
else if (symbol.flags & SymbolFlags.Transient) {
|
||||
const target = getSymbolLinks(symbol).target;
|
||||
let target: Symbol;
|
||||
let next = symbol;
|
||||
while (next = getSymbolLinks(next).target) {
|
||||
target = next;
|
||||
}
|
||||
if (target) {
|
||||
return [target];
|
||||
}
|
||||
|
||||
@@ -1565,6 +1565,12 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isLiteralComputedPropertyDeclarationName(node: Node) {
|
||||
return (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) &&
|
||||
node.parent.kind === SyntaxKind.ComputedPropertyName &&
|
||||
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;
|
||||
@@ -1750,6 +1756,9 @@ namespace ts {
|
||||
const rightHandSideName = (<PropertyAccessExpression>nameExpression).name.text;
|
||||
return getPropertyNameForKnownSymbolName(rightHandSideName);
|
||||
}
|
||||
else if (nameExpression.kind === SyntaxKind.StringLiteral || nameExpression.kind === SyntaxKind.NumericLiteral) {
|
||||
return (<LiteralExpression>nameExpression).text;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
+69
-40
@@ -2581,10 +2581,33 @@ namespace ts {
|
||||
isFunctionLike(node.parent) && (<FunctionLikeDeclaration>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 {
|
||||
return (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) &&
|
||||
(node.parent.kind === SyntaxKind.PropertyAssignment || node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) && (<PropertyDeclaration>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 {
|
||||
@@ -2602,6 +2625,8 @@ namespace ts {
|
||||
return (<Declaration>node.parent).name === node;
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return (<ElementAccessExpression>node.parent).argumentExpression === node;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6208,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);
|
||||
@@ -6234,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));
|
||||
});
|
||||
|
||||
@@ -6362,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);
|
||||
});
|
||||
|
||||
@@ -6409,37 +6436,38 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getPropertySymbolsFromContextualType(node: Node): Symbol[] {
|
||||
if (isNameOfPropertyAssignment(node)) {
|
||||
const objectLiteral = <ObjectLiteralExpression>node.parent.parent;
|
||||
const contextualType = typeChecker.getContextualType(objectLiteral);
|
||||
const name = (<Identifier>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((<UnionType>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];
|
||||
}
|
||||
}
|
||||
function getNameFromObjectLiteralElement(node: ObjectLiteralElement) {
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
const nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
// treat computed property names where expression is string/numeric literal as just string/numeric literal
|
||||
if (isStringOrNumericLiteral(nameExpression.kind)) {
|
||||
return (<LiteralExpression>nameExpression).text;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
return (<Identifier | LiteralExpression>node.name).text;
|
||||
}
|
||||
|
||||
function getPropertySymbolsFromContextualType(node: ObjectLiteralElement): Symbol[] {
|
||||
const objectLiteral = <ObjectLiteralExpression>node.parent;
|
||||
const contextualType = typeChecker.getContextualType(objectLiteral);
|
||||
const name = getNameFromObjectLiteralElement(node);
|
||||
if (name && contextualType) {
|
||||
const result: Symbol[] = [];
|
||||
const symbol = contextualType.getProperty(name);
|
||||
if (symbol) {
|
||||
result.push(symbol);
|
||||
}
|
||||
|
||||
if (contextualType.flags & TypeFlags.Union) {
|
||||
forEach((<UnionType>contextualType).types, t => {
|
||||
const symbol = t.getProperty(name);
|
||||
if (symbol) {
|
||||
result.push(symbol);
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -7901,7 +7929,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[(<LiteralExpression>node).text] = nameTable[(<LiteralExpression>node).text] === undefined ? node.pos : -1;
|
||||
}
|
||||
|
||||
@@ -821,6 +821,10 @@ namespace ts {
|
||||
if (isImportOrExportSpecifierName(location)) {
|
||||
return location.getText();
|
||||
}
|
||||
else if (isStringOrNumericLiteral(location.kind) &&
|
||||
location.parent.kind === SyntaxKind.ComputedPropertyName) {
|
||||
return (<LiteralExpression>location).text;
|
||||
}
|
||||
|
||||
// Try to get the local symbol if we're dealing with an 'export default'
|
||||
// since that symbol has the "true" name.
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, --, --))
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
=== tests/cases/compiler/exportEqualsAmd.ts ===
|
||||
export = { ["hi"]: "there" };
|
||||
No type information for this code.
|
||||
>"hi" : Symbol(["hi"], Decl(exportEqualsAmd.ts, 0, 10))
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
=== tests/cases/compiler/exportEqualsCommonJs.ts ===
|
||||
export = { ["hi"]: "there" };
|
||||
No type information for this code.
|
||||
>"hi" : Symbol(["hi"], Decl(exportEqualsCommonJs.ts, 0, 10))
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
=== tests/cases/compiler/exportEqualsUmd.ts ===
|
||||
export = { ["hi"]: "there" };
|
||||
No type information for this code.
|
||||
>"hi" : Symbol(["hi"], Decl(exportEqualsUmd.ts, 0, 10))
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
|
||||
////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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////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 () { }
|
||||
////};
|
||||
////
|
||||
////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) {
|
||||
goTo.file(range.fileName);
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////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 () { }
|
||||
////};
|
||||
////
|
||||
////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) {
|
||||
goTo.file(range.fileName);
|
||||
goTo.position(range.start);
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
Reference in New Issue
Block a user