Merge pull request #13648 from Microsoft/functionAndClassProperties
Function and class properties
This commit is contained in:
commit
6c58938743
25 changed files with 238 additions and 125 deletions
|
@ -265,6 +265,7 @@ namespace ts {
|
|||
return "export=";
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
case SpecialPropertyAssignmentKind.Property:
|
||||
// exports.x = ... or this.y = ...
|
||||
return ((node as BinaryExpression).left as PropertyAccessExpression).name.text;
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
|
@ -1969,6 +1970,9 @@ namespace ts {
|
|||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
bindThisPropertyAssignment(<BinaryExpression>node);
|
||||
break;
|
||||
case SpecialPropertyAssignmentKind.Property:
|
||||
bindStaticPropertyAssignment(<BinaryExpression>node);
|
||||
break;
|
||||
case SpecialPropertyAssignmentKind.None:
|
||||
// Nothing to do
|
||||
break;
|
||||
|
@ -2265,18 +2269,41 @@ namespace ts {
|
|||
constructorFunction.parent = classPrototype;
|
||||
classPrototype.parent = leftSideOfAssignment;
|
||||
|
||||
const funcSymbol = container.locals.get(constructorFunction.text);
|
||||
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
|
||||
bindPropertyAssignment(constructorFunction.text, leftSideOfAssignment, /*isPrototypeProperty*/ true);
|
||||
}
|
||||
|
||||
function bindStaticPropertyAssignment(node: BinaryExpression) {
|
||||
// We saw a node of the form 'x.y = z'. Declare a 'member' y on x if x was a function.
|
||||
|
||||
// Look up the function in the local scope, since prototype assignments should
|
||||
// follow the function declaration
|
||||
const leftSideOfAssignment = node.left as PropertyAccessExpression;
|
||||
const target = leftSideOfAssignment.expression as Identifier;
|
||||
|
||||
// Fix up parent pointers since we're going to use these nodes before we bind into them
|
||||
leftSideOfAssignment.parent = node;
|
||||
target.parent = leftSideOfAssignment;
|
||||
|
||||
bindPropertyAssignment(target.text, leftSideOfAssignment, /*isPrototypeProperty*/ false);
|
||||
}
|
||||
|
||||
function bindPropertyAssignment(functionName: string, propertyAccessExpression: PropertyAccessExpression, isPrototypeProperty: boolean) {
|
||||
let targetSymbol = container.locals.get(functionName);
|
||||
if (targetSymbol && isDeclarationOfFunctionOrClassExpression(targetSymbol)) {
|
||||
targetSymbol = (targetSymbol.valueDeclaration as VariableDeclaration).initializer.symbol;
|
||||
}
|
||||
|
||||
if (!targetSymbol || !(targetSymbol.flags & (SymbolFlags.Function | SymbolFlags.Class))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the members collection if it doesn't exist already
|
||||
if (!funcSymbol.members) {
|
||||
funcSymbol.members = createMap<Symbol>();
|
||||
}
|
||||
const symbolTable = isPrototypeProperty ?
|
||||
(targetSymbol.members || (targetSymbol.members = createMap<Symbol>())) :
|
||||
(targetSymbol.exports || (targetSymbol.exports = createMap<Symbol>()));
|
||||
|
||||
// Declare the method/property
|
||||
declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
declareSymbol(symbolTable, targetSymbol, propertyAccessExpression, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
|
||||
function bindCallExpression(node: CallExpression) {
|
||||
|
|
|
@ -2184,13 +2184,15 @@ namespace ts {
|
|||
return type.flags & TypeFlags.StringLiteral ? `"${escapeString((<LiteralType>type).text)}"` : (<LiteralType>type).text;
|
||||
}
|
||||
|
||||
|
||||
function getNameOfSymbol(symbol: Symbol): string {
|
||||
if (symbol.declarations && symbol.declarations.length) {
|
||||
const declaration = symbol.declarations[0];
|
||||
if (declaration.name) {
|
||||
return declarationNameToString(declaration.name);
|
||||
}
|
||||
if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) {
|
||||
return declarationNameToString((<VariableDeclaration>declaration.parent).name);
|
||||
}
|
||||
switch (declaration.kind) {
|
||||
case SyntaxKind.ClassExpression:
|
||||
return "(Anonymous class)";
|
||||
|
@ -4692,7 +4694,7 @@ namespace ts {
|
|||
// Combinations of function, class, enum and module
|
||||
let members = emptySymbols;
|
||||
let constructSignatures: Signature[] = emptyArray;
|
||||
if (symbol.flags & SymbolFlags.HasExports) {
|
||||
if (symbol.exports) {
|
||||
members = getExportsOfSymbol(symbol);
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
|
@ -14577,10 +14579,13 @@ namespace ts {
|
|||
// in a JS file
|
||||
// Note:JS inferred classes might come from a variable declaration instead of a function declaration.
|
||||
// In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration.
|
||||
const funcSymbol = node.expression.kind === SyntaxKind.Identifier ?
|
||||
let funcSymbol = node.expression.kind === SyntaxKind.Identifier ?
|
||||
getResolvedSymbol(node.expression as Identifier) :
|
||||
checkExpression(node.expression).symbol;
|
||||
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
|
||||
if (funcSymbol && isDeclarationOfFunctionOrClassExpression(funcSymbol)) {
|
||||
funcSymbol = getSymbolOfNode((<VariableDeclaration>funcSymbol.valueDeclaration).initializer);
|
||||
}
|
||||
if (funcSymbol && funcSymbol.members && funcSymbol.flags & SymbolFlags.Function) {
|
||||
return getInferredClassType(funcSymbol);
|
||||
}
|
||||
else if (compilerOptions.noImplicitAny) {
|
||||
|
@ -20629,22 +20634,29 @@ namespace ts {
|
|||
return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined;
|
||||
}
|
||||
|
||||
function getSpecialPropertyAssignmentSymbolFromEntityName(entityName: EntityName | PropertyAccessExpression) {
|
||||
const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent);
|
||||
switch (specialPropertyAssignmentKind) {
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
return getSymbolOfNode(entityName.parent);
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
case SpecialPropertyAssignmentKind.Property:
|
||||
return getSymbolOfNode(entityName.parent.parent);
|
||||
}
|
||||
}
|
||||
|
||||
function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol | undefined {
|
||||
if (isDeclarationName(entityName)) {
|
||||
return getSymbolOfNode(entityName.parent);
|
||||
}
|
||||
|
||||
if (isInJavaScriptFile(entityName) && entityName.parent.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent);
|
||||
switch (specialPropertyAssignmentKind) {
|
||||
case SpecialPropertyAssignmentKind.ExportsProperty:
|
||||
case SpecialPropertyAssignmentKind.PrototypeProperty:
|
||||
return getSymbolOfNode(entityName.parent);
|
||||
case SpecialPropertyAssignmentKind.ThisProperty:
|
||||
case SpecialPropertyAssignmentKind.ModuleExports:
|
||||
return getSymbolOfNode(entityName.parent.parent);
|
||||
default:
|
||||
// Fall through if it is not a special property assignment
|
||||
// Check if this is a special property assignment
|
||||
const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName);
|
||||
if (specialPropertyAssignmentSymbol) {
|
||||
return specialPropertyAssignmentSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3180,7 +3180,9 @@
|
|||
/// className.prototype.name = expr
|
||||
PrototypeProperty,
|
||||
/// this.name = expr
|
||||
ThisProperty
|
||||
ThisProperty,
|
||||
// F.name = expr
|
||||
Property
|
||||
}
|
||||
|
||||
export interface JsFileExtensionInfo {
|
||||
|
|
|
@ -1417,10 +1417,10 @@ namespace ts {
|
|||
* Returns true if the node is a variable declaration whose initializer is a function expression.
|
||||
* This function does not test if the node is in a JavaScript file or not.
|
||||
*/
|
||||
export function isDeclarationOfFunctionExpression(s: Symbol) {
|
||||
export function isDeclarationOfFunctionOrClassExpression(s: Symbol) {
|
||||
if (s.valueDeclaration && s.valueDeclaration.kind === SyntaxKind.VariableDeclaration) {
|
||||
const declaration = s.valueDeclaration as VariableDeclaration;
|
||||
return declaration.initializer && declaration.initializer.kind === SyntaxKind.FunctionExpression;
|
||||
return declaration.initializer && (declaration.initializer.kind === SyntaxKind.FunctionExpression || declaration.initializer.kind === SyntaxKind.ClassExpression);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1449,6 +1449,10 @@ namespace ts {
|
|||
// module.exports = expr
|
||||
return SpecialPropertyAssignmentKind.ModuleExports;
|
||||
}
|
||||
else {
|
||||
// F.x = expr
|
||||
return SpecialPropertyAssignmentKind.Property;
|
||||
}
|
||||
}
|
||||
else if (lhs.expression.kind === SyntaxKind.ThisKeyword) {
|
||||
return SpecialPropertyAssignmentKind.ThisProperty;
|
||||
|
@ -1468,6 +1472,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return SpecialPropertyAssignmentKind.None;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
|
|||
>C : Symbol(C, Decl(classExpression3.ts, 0, 3))
|
||||
>a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43))
|
||||
>b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53))
|
||||
>c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63))
|
||||
>c : Symbol(C.c, Decl(classExpression3.ts, 0, 63))
|
||||
|
||||
let c = new C();
|
||||
>c : Symbol(c, Decl(classExpression3.ts, 1, 3))
|
||||
|
@ -20,7 +20,7 @@ c.b;
|
|||
>b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53))
|
||||
|
||||
c.c;
|
||||
>c.c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63))
|
||||
>c.c : Symbol(C.c, Decl(classExpression3.ts, 0, 63))
|
||||
>c : Symbol(c, Decl(classExpression3.ts, 1, 3))
|
||||
>c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63))
|
||||
>c : Symbol(C.c, Decl(classExpression3.ts, 0, 63))
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
=== tests/cases/conformance/classes/classExpressions/classExpression3.ts ===
|
||||
let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
|
||||
>C : typeof (Anonymous class)
|
||||
>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class)
|
||||
>C : typeof C
|
||||
>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof C
|
||||
>class extends class { a = 1 } { b = 2 } : (Anonymous class)
|
||||
>class { a = 1 } : (Anonymous class)
|
||||
>a : number
|
||||
|
@ -12,22 +12,22 @@ let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
|
|||
>3 : 3
|
||||
|
||||
let c = new C();
|
||||
>c : (Anonymous class)
|
||||
>new C() : (Anonymous class)
|
||||
>C : typeof (Anonymous class)
|
||||
>c : C
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
|
||||
c.a;
|
||||
>c.a : number
|
||||
>c : (Anonymous class)
|
||||
>c : C
|
||||
>a : number
|
||||
|
||||
c.b;
|
||||
>c.b : number
|
||||
>c : (Anonymous class)
|
||||
>c : C
|
||||
>b : number
|
||||
|
||||
c.c;
|
||||
>c.c : number
|
||||
>c : (Anonymous class)
|
||||
>c : C
|
||||
>c : number
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ let C = class {
|
|||
>C : Symbol(C, Decl(classExpression4.ts, 0, 3))
|
||||
|
||||
foo() {
|
||||
>foo : Symbol((Anonymous class).foo, Decl(classExpression4.ts, 0, 15))
|
||||
>foo : Symbol(C.foo, Decl(classExpression4.ts, 0, 15))
|
||||
|
||||
return new C();
|
||||
>C : Symbol(C, Decl(classExpression4.ts, 0, 3))
|
||||
|
@ -11,7 +11,7 @@ let C = class {
|
|||
};
|
||||
let x = (new C).foo();
|
||||
>x : Symbol(x, Decl(classExpression4.ts, 5, 3))
|
||||
>(new C).foo : Symbol((Anonymous class).foo, Decl(classExpression4.ts, 0, 15))
|
||||
>(new C).foo : Symbol(C.foo, Decl(classExpression4.ts, 0, 15))
|
||||
>C : Symbol(C, Decl(classExpression4.ts, 0, 3))
|
||||
>foo : Symbol((Anonymous class).foo, Decl(classExpression4.ts, 0, 15))
|
||||
>foo : Symbol(C.foo, Decl(classExpression4.ts, 0, 15))
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
=== tests/cases/conformance/classes/classExpressions/classExpression4.ts ===
|
||||
let C = class {
|
||||
>C : typeof (Anonymous class)
|
||||
>class { foo() { return new C(); }} : typeof (Anonymous class)
|
||||
>C : typeof C
|
||||
>class { foo() { return new C(); }} : typeof C
|
||||
|
||||
foo() {
|
||||
>foo : () => (Anonymous class)
|
||||
>foo : () => C
|
||||
|
||||
return new C();
|
||||
>new C() : (Anonymous class)
|
||||
>C : typeof (Anonymous class)
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
}
|
||||
};
|
||||
let x = (new C).foo();
|
||||
>x : (Anonymous class)
|
||||
>(new C).foo() : (Anonymous class)
|
||||
>(new C).foo : () => (Anonymous class)
|
||||
>(new C) : (Anonymous class)
|
||||
>new C : (Anonymous class)
|
||||
>C : typeof (Anonymous class)
|
||||
>foo : () => (Anonymous class)
|
||||
>x : C
|
||||
>(new C).foo() : C
|
||||
>(new C).foo : () => C
|
||||
>(new C) : C
|
||||
>new C : C
|
||||
>C : typeof C
|
||||
>foo : () => C
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
|
|||
>C : Symbol(C, Decl(classExpressionES63.ts, 0, 3))
|
||||
>a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43))
|
||||
>b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53))
|
||||
>c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63))
|
||||
>c : Symbol(C.c, Decl(classExpressionES63.ts, 0, 63))
|
||||
|
||||
let c = new C();
|
||||
>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3))
|
||||
|
@ -20,7 +20,7 @@ c.b;
|
|||
>b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53))
|
||||
|
||||
c.c;
|
||||
>c.c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63))
|
||||
>c.c : Symbol(C.c, Decl(classExpressionES63.ts, 0, 63))
|
||||
>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3))
|
||||
>c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63))
|
||||
>c : Symbol(C.c, Decl(classExpressionES63.ts, 0, 63))
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
=== tests/cases/conformance/es6/classExpressions/classExpressionES63.ts ===
|
||||
let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
|
||||
>C : typeof (Anonymous class)
|
||||
>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class)
|
||||
>C : typeof C
|
||||
>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof C
|
||||
>class extends class { a = 1 } { b = 2 } : (Anonymous class)
|
||||
>class { a = 1 } : (Anonymous class)
|
||||
>a : number
|
||||
|
@ -12,22 +12,22 @@ let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 };
|
|||
>3 : 3
|
||||
|
||||
let c = new C();
|
||||
>c : (Anonymous class)
|
||||
>new C() : (Anonymous class)
|
||||
>C : typeof (Anonymous class)
|
||||
>c : C
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
|
||||
c.a;
|
||||
>c.a : number
|
||||
>c : (Anonymous class)
|
||||
>c : C
|
||||
>a : number
|
||||
|
||||
c.b;
|
||||
>c.b : number
|
||||
>c : (Anonymous class)
|
||||
>c : C
|
||||
>b : number
|
||||
|
||||
c.c;
|
||||
>c.c : number
|
||||
>c : (Anonymous class)
|
||||
>c : C
|
||||
>c : number
|
||||
|
||||
|
|
|
@ -4,24 +4,24 @@ let Foo = class {
|
|||
|
||||
constructor() {
|
||||
this.bar++;
|
||||
>this.bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>this : Symbol((Anonymous class), Decl(functionsInClassExpressions.ts, 0, 9))
|
||||
>bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>this.bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>this : Symbol(Foo, Decl(functionsInClassExpressions.ts, 0, 9))
|
||||
>bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
}
|
||||
bar = 0;
|
||||
>bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
|
||||
inc = () => {
|
||||
>inc : Symbol((Anonymous class).inc, Decl(functionsInClassExpressions.ts, 4, 12))
|
||||
>inc : Symbol(Foo.inc, Decl(functionsInClassExpressions.ts, 4, 12))
|
||||
|
||||
this.bar++;
|
||||
>this.bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>this : Symbol((Anonymous class), Decl(functionsInClassExpressions.ts, 0, 9))
|
||||
>bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>this.bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>this : Symbol(Foo, Decl(functionsInClassExpressions.ts, 0, 9))
|
||||
>bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
}
|
||||
m() { return this.bar; }
|
||||
>m : Symbol((Anonymous class).m, Decl(functionsInClassExpressions.ts, 7, 5))
|
||||
>this.bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>this : Symbol((Anonymous class), Decl(functionsInClassExpressions.ts, 0, 9))
|
||||
>bar : Symbol((Anonymous class).bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>m : Symbol(Foo.m, Decl(functionsInClassExpressions.ts, 7, 5))
|
||||
>this.bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
>this : Symbol(Foo, Decl(functionsInClassExpressions.ts, 0, 9))
|
||||
>bar : Symbol(Foo.bar, Decl(functionsInClassExpressions.ts, 3, 5))
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
=== tests/cases/compiler/functionsInClassExpressions.ts ===
|
||||
let Foo = class {
|
||||
>Foo : typeof (Anonymous class)
|
||||
>class { constructor() { this.bar++; } bar = 0; inc = () => { this.bar++; } m() { return this.bar; }} : typeof (Anonymous class)
|
||||
>Foo : typeof Foo
|
||||
>class { constructor() { this.bar++; } bar = 0; inc = () => { this.bar++; } m() { return this.bar; }} : typeof Foo
|
||||
|
||||
constructor() {
|
||||
this.bar++;
|
||||
|
|
|
@ -11,5 +11,5 @@ let cls = class implements Foo {
|
|||
>Foo : Symbol(Foo, Decl(implementsInClassExpression.ts, 0, 0))
|
||||
|
||||
doThing() { }
|
||||
>doThing : Symbol((Anonymous class).doThing, Decl(implementsInClassExpression.ts, 4, 32))
|
||||
>doThing : Symbol(cls.doThing, Decl(implementsInClassExpression.ts, 4, 32))
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ interface Foo {
|
|||
}
|
||||
|
||||
let cls = class implements Foo {
|
||||
>cls : typeof (Anonymous class)
|
||||
>class implements Foo { doThing() { }} : typeof (Anonymous class)
|
||||
>cls : typeof cls
|
||||
>class implements Foo { doThing() { }} : typeof cls
|
||||
>Foo : Foo
|
||||
|
||||
doThing() { }
|
||||
|
|
|
@ -30,7 +30,7 @@ class X {
|
|||
>this : Symbol(X, Decl(input.js, 5, 1))
|
||||
|
||||
this.mistake = 'frankly, complete nonsense';
|
||||
>this.mistake : Symbol(X.mistake, Decl(input.js, 12, 5))
|
||||
>this.mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16))
|
||||
>this : Symbol(X, Decl(input.js, 5, 1))
|
||||
>mistake : Symbol(X.mistake, Decl(input.js, 8, 35))
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class X {
|
|||
>m : Symbol(X.m, Decl(input.js, 10, 5))
|
||||
}
|
||||
mistake() {
|
||||
>mistake : Symbol(X.mistake, Decl(input.js, 12, 5))
|
||||
>mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16))
|
||||
}
|
||||
}
|
||||
let x = new X();
|
||||
|
@ -46,9 +46,11 @@ let x = new X();
|
|||
>X : Symbol(X, Decl(input.js, 5, 1))
|
||||
|
||||
X.prototype.mistake = false;
|
||||
>X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 12, 5))
|
||||
>X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16))
|
||||
>X.prototype : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16))
|
||||
>X : Symbol(X, Decl(input.js, 5, 1))
|
||||
>prototype : Symbol(X.prototype)
|
||||
>mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16))
|
||||
|
||||
x.m();
|
||||
>x.m : Symbol(X.m, Decl(input.js, 10, 5))
|
||||
|
@ -56,15 +58,15 @@ x.m();
|
|||
>m : Symbol(X.m, Decl(input.js, 10, 5))
|
||||
|
||||
x.mistake;
|
||||
>x.mistake : Symbol(X.mistake, Decl(input.js, 12, 5))
|
||||
>x.mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16))
|
||||
>x : Symbol(x, Decl(input.js, 16, 3))
|
||||
>mistake : Symbol(X.mistake, Decl(input.js, 12, 5))
|
||||
>mistake : Symbol(X.mistake, Decl(input.js, 12, 5), Decl(input.js, 16, 16))
|
||||
|
||||
class Y {
|
||||
>Y : Symbol(Y, Decl(input.js, 19, 10))
|
||||
|
||||
mistake() {
|
||||
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
|
||||
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1))
|
||||
}
|
||||
m() {
|
||||
>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19))
|
||||
|
@ -80,15 +82,17 @@ class Y {
|
|||
>this : Symbol(Y, Decl(input.js, 19, 10))
|
||||
|
||||
this.mistake = 'even more nonsense';
|
||||
>this.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
|
||||
>this.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1))
|
||||
>this : Symbol(Y, Decl(input.js, 19, 10))
|
||||
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
|
||||
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1))
|
||||
}
|
||||
}
|
||||
Y.prototype.mistake = true;
|
||||
>Y.prototype.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
|
||||
>Y.prototype.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1))
|
||||
>Y.prototype : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1))
|
||||
>Y : Symbol(Y, Decl(input.js, 19, 10))
|
||||
>prototype : Symbol(Y.prototype)
|
||||
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1))
|
||||
|
||||
let y = new Y();
|
||||
>y : Symbol(y, Decl(input.js, 31, 3))
|
||||
|
@ -100,7 +104,7 @@ y.m();
|
|||
>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19))
|
||||
|
||||
y.mistake();
|
||||
>y.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
|
||||
>y.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1))
|
||||
>y : Symbol(y, Decl(input.js, 31, 3))
|
||||
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35))
|
||||
>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35), Decl(input.js, 29, 1))
|
||||
|
||||
|
|
|
@ -43,16 +43,16 @@ class X {
|
|||
|
||||
this.mistake = 'frankly, complete nonsense';
|
||||
>this.mistake = 'frankly, complete nonsense' : "frankly, complete nonsense"
|
||||
>this.mistake : () => void
|
||||
>this.mistake : any
|
||||
>this : this
|
||||
>mistake : () => void
|
||||
>mistake : any
|
||||
>'frankly, complete nonsense' : "frankly, complete nonsense"
|
||||
}
|
||||
m() {
|
||||
>m : () => void
|
||||
}
|
||||
mistake() {
|
||||
>mistake : () => void
|
||||
>mistake : any
|
||||
}
|
||||
}
|
||||
let x = new X();
|
||||
|
@ -62,11 +62,11 @@ let x = new X();
|
|||
|
||||
X.prototype.mistake = false;
|
||||
>X.prototype.mistake = false : false
|
||||
>X.prototype.mistake : () => void
|
||||
>X.prototype.mistake : any
|
||||
>X.prototype : X
|
||||
>X : typeof X
|
||||
>prototype : X
|
||||
>mistake : () => void
|
||||
>mistake : any
|
||||
>false : false
|
||||
|
||||
x.m();
|
||||
|
@ -76,9 +76,9 @@ x.m();
|
|||
>m : () => void
|
||||
|
||||
x.mistake;
|
||||
>x.mistake : () => void
|
||||
>x.mistake : any
|
||||
>x : X
|
||||
>mistake : () => void
|
||||
>mistake : any
|
||||
|
||||
class Y {
|
||||
>Y : Y
|
||||
|
|
|
@ -9,17 +9,17 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
|
|||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(41,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(47,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(52,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(62,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(67,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(73,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(78,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(84,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(62,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(67,12): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(73,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(78,12): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(84,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(89,12): error TS2300: Duplicate identifier 'prototype'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(89,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(95,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(100,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(106,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(111,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function '(Anonymous class)'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(89,12): error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(95,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(100,12): error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(106,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(111,12): error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn_Anonymous'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(121,16): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(128,16): error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn'.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts(136,16): error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength'.
|
||||
|
@ -119,14 +119,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
|
|||
var StaticName_Anonymous = class {
|
||||
static name: number; // error
|
||||
~~~~
|
||||
!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticName_Anonymous'.
|
||||
name: string; // ok
|
||||
}
|
||||
|
||||
var StaticNameFn_Anonymous = class {
|
||||
static name() {} // error
|
||||
~~~~
|
||||
!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'name' conflicts with built-in property 'Function.name' of constructor function 'StaticNameFn_Anonymous'.
|
||||
name() {} // ok
|
||||
}
|
||||
|
||||
|
@ -134,14 +134,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
|
|||
var StaticLength_Anonymous = class {
|
||||
static length: number; // error
|
||||
~~~~~~
|
||||
!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLength_Anonymous'.
|
||||
length: string; // ok
|
||||
}
|
||||
|
||||
var StaticLengthFn_Anonymous = class {
|
||||
static length() {} // error
|
||||
~~~~~~
|
||||
!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'length' conflicts with built-in property 'Function.length' of constructor function 'StaticLengthFn_Anonymous'.
|
||||
length() {} // ok
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
|
|||
var StaticPrototype_Anonymous = class {
|
||||
static prototype: number; // error
|
||||
~~~~~~~~~
|
||||
!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototype_Anonymous'.
|
||||
prototype: string; // ok
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
|
|||
~~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'prototype'.
|
||||
~~~~~~~~~
|
||||
!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'prototype' conflicts with built-in property 'Function.prototype' of constructor function 'StaticPrototypeFn_Anonymous'.
|
||||
prototype() {} // ok
|
||||
}
|
||||
|
||||
|
@ -166,14 +166,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
|
|||
var StaticCaller_Anonymous = class {
|
||||
static caller: number; // error
|
||||
~~~~~~
|
||||
!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCaller_Anonymous'.
|
||||
caller: string; // ok
|
||||
}
|
||||
|
||||
var StaticCallerFn_Anonymous = class {
|
||||
static caller() {} // error
|
||||
~~~~~~
|
||||
!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'caller' conflicts with built-in property 'Function.caller' of constructor function 'StaticCallerFn_Anonymous'.
|
||||
caller() {} // ok
|
||||
}
|
||||
|
||||
|
@ -181,14 +181,14 @@ tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameCon
|
|||
var StaticArguments_Anonymous = class {
|
||||
static arguments: number; // error
|
||||
~~~~~~~~~
|
||||
!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArguments_Anonymous'.
|
||||
arguments: string; // ok
|
||||
}
|
||||
|
||||
var StaticArgumentsFn_Anonymous = class {
|
||||
static arguments() {} // error
|
||||
~~~~~~~~~
|
||||
!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function '(Anonymous class)'.
|
||||
!!! error TS2699: Static property 'arguments' conflicts with built-in property 'Function.arguments' of constructor function 'StaticArgumentsFn_Anonymous'.
|
||||
arguments() {} // ok
|
||||
}
|
||||
|
||||
|
|
|
@ -140,14 +140,14 @@ class C5 {
|
|||
}
|
||||
|
||||
var C6 = class { constructor(p12: null) { } }
|
||||
>C6 : typeof (Anonymous class)
|
||||
>class { constructor(p12: null) { } } : typeof (Anonymous class)
|
||||
>C6 : typeof C6
|
||||
>class { constructor(p12: null) { } } : typeof C6
|
||||
>p12 : null
|
||||
>null : null
|
||||
|
||||
var C7 = class { constructor(p13: undefined) { } }
|
||||
>C7 : typeof (Anonymous class)
|
||||
>class { constructor(p13: undefined) { } } : typeof (Anonymous class)
|
||||
>C7 : typeof C7
|
||||
>class { constructor(p13: undefined) { } } : typeof C7
|
||||
>p13 : undefined
|
||||
|
||||
declare function fn<T>();
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
////var [|{| "isWriteAccess": true, "isDefinition": true |}Base|] = class { };
|
||||
////class C extends [|Base|] { }
|
||||
|
||||
verify.singleReferenceGroup("var Base: typeof (Anonymous class)");
|
||||
verify.singleReferenceGroup("var Base: typeof Base");
|
||||
|
|
|
@ -18,4 +18,4 @@
|
|||
//// Person.getNa/**/ = 10;
|
||||
|
||||
goTo.marker();
|
||||
verify.not.completionListContains('getNa');
|
||||
verify.completionListContains('getName');
|
||||
|
|
11
tests/cases/fourslash/renameJsPropertyAssignment.ts
Normal file
11
tests/cases/fourslash/renameJsPropertyAssignment.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
////function bar() {
|
||||
////}
|
||||
////bar.[|foo|] = "foo";
|
||||
////console.log(bar./**/[|foo|]);
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
|
11
tests/cases/fourslash/renameJsPropertyAssignment2.ts
Normal file
11
tests/cases/fourslash/renameJsPropertyAssignment2.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
////class Minimatch {
|
||||
////}
|
||||
////Minimatch.[|staticProperty|] = "string";
|
||||
////console.log(Minimatch./**/[|staticProperty|]);
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
|
11
tests/cases/fourslash/renameJsPropertyAssignment3.ts
Normal file
11
tests/cases/fourslash/renameJsPropertyAssignment3.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
////var C = class {
|
||||
////}
|
||||
////C.[|staticProperty|] = "string";
|
||||
////console.log(C./**/[|staticProperty|]);
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
|
15
tests/cases/fourslash/renameJsThisProperty05.ts
Normal file
15
tests/cases/fourslash/renameJsThisProperty05.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
////class C {
|
||||
//// constructor(y) {
|
||||
//// this.x = y;
|
||||
//// }
|
||||
////}
|
||||
////C.prototype.[|z|] = 1;
|
||||
////var t = new C(12);
|
||||
////t./**/[|z|] = 11;
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
|
15
tests/cases/fourslash/renameJsThisProperty06.ts
Normal file
15
tests/cases/fourslash/renameJsThisProperty06.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
////var C = class {
|
||||
//// constructor(y) {
|
||||
//// this.x = y;
|
||||
//// }
|
||||
////}
|
||||
////C.prototype.[|z|] = 1;
|
||||
////var t = new C(12);
|
||||
////t./**/[|z|] = 11;
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations( /*findInStrings*/ false, /*findInComments*/ false);
|
Loading…
Reference in a new issue