mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Make goto-definition work for this parameter
This commit is contained in:
+29
-8
@@ -134,8 +134,8 @@ namespace ts {
|
||||
|
||||
const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
|
||||
const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
|
||||
const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
|
||||
const anySignature = createSignature(undefined, undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
|
||||
const unknownSignature = createSignature(undefined, undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
|
||||
|
||||
const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true);
|
||||
|
||||
@@ -3198,6 +3198,11 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getAnnotatedAccessorThisParameter(accessor: AccessorDeclaration): Symbol {
|
||||
const parameter = getAccessorThisParameter(accessor);
|
||||
return parameter && parameter.symbol;
|
||||
}
|
||||
|
||||
function getAnnotatedAccessorThisType(accessor: AccessorDeclaration): Type {
|
||||
if (accessor) {
|
||||
const parameter = getAccessorThisParameter(accessor);
|
||||
@@ -3888,12 +3893,13 @@ namespace ts {
|
||||
resolveObjectTypeMembers(type, source, typeParameters, typeArguments);
|
||||
}
|
||||
|
||||
function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], thisType: Type, parameters: Symbol[],
|
||||
function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], thisParameter: Symbol | undefined, thisType: Type | undefined, parameters: Symbol[],
|
||||
resolvedReturnType: Type, typePredicate: TypePredicate, minArgumentCount: number, hasRestParameter: boolean, hasStringLiterals: boolean): Signature {
|
||||
const sig = new Signature(checker);
|
||||
sig.declaration = declaration;
|
||||
sig.typeParameters = typeParameters;
|
||||
sig.parameters = parameters;
|
||||
sig.thisParameter = thisParameter;
|
||||
sig.thisType = thisType;
|
||||
sig.resolvedReturnType = resolvedReturnType;
|
||||
sig.typePredicate = typePredicate;
|
||||
@@ -3904,7 +3910,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function cloneSignature(sig: Signature): Signature {
|
||||
return createSignature(sig.declaration, sig.typeParameters, sig.thisType, sig.parameters, sig.resolvedReturnType,
|
||||
return createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.thisType, sig.parameters, sig.resolvedReturnType,
|
||||
sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
|
||||
}
|
||||
|
||||
@@ -3912,7 +3918,7 @@ namespace ts {
|
||||
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
||||
const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct);
|
||||
if (baseSignatures.length === 0) {
|
||||
return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)];
|
||||
return [createSignature(undefined, classType.localTypeParameters, undefined, undefined, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)];
|
||||
}
|
||||
const baseTypeNode = getBaseTypeNodeOfClass(classType);
|
||||
const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode);
|
||||
@@ -4454,6 +4460,7 @@ namespace ts {
|
||||
const parameters: Symbol[] = [];
|
||||
let hasStringLiterals = false;
|
||||
let minArgumentCount = -1;
|
||||
let thisParameter: Symbol = undefined;
|
||||
let thisType: Type = undefined;
|
||||
let hasThisParameter: boolean;
|
||||
const isJSConstructSignature = isJSDocConstructSignature(declaration);
|
||||
@@ -4472,6 +4479,7 @@ namespace ts {
|
||||
}
|
||||
if (i === 0 && paramSymbol.name === "this") {
|
||||
hasThisParameter = true;
|
||||
thisParameter = param.symbol;
|
||||
thisType = param.type ? getTypeFromTypeNode(param.type) : unknownType;
|
||||
}
|
||||
else {
|
||||
@@ -4498,8 +4506,11 @@ namespace ts {
|
||||
!hasDynamicName(declaration) &&
|
||||
(!hasThisParameter || thisType === unknownType)) {
|
||||
const otherKind = declaration.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
|
||||
const setter = <AccessorDeclaration>getDeclarationOfKind(declaration.symbol, otherKind);
|
||||
thisType = getAnnotatedAccessorThisType(setter);
|
||||
const other = <AccessorDeclaration>getDeclarationOfKind(declaration.symbol, otherKind);
|
||||
if (other) {
|
||||
thisParameter = getAnnotatedAccessorThisParameter(other);
|
||||
thisType = getAnnotatedAccessorThisType(other);
|
||||
}
|
||||
}
|
||||
|
||||
if (minArgumentCount < 0) {
|
||||
@@ -4520,7 +4531,7 @@ namespace ts {
|
||||
createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) :
|
||||
undefined;
|
||||
|
||||
links.resolvedSignature = createSignature(declaration, typeParameters, thisType, parameters, returnType, typePredicate, minArgumentCount, hasRestParameter(declaration), hasStringLiterals);
|
||||
links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, thisType, parameters, returnType, typePredicate, minArgumentCount, hasRestParameter(declaration), hasStringLiterals);
|
||||
}
|
||||
return links.resolvedSignature;
|
||||
}
|
||||
@@ -5453,6 +5464,7 @@ namespace ts {
|
||||
freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper);
|
||||
}
|
||||
const result = createSignature(signature.declaration, freshTypeParameters,
|
||||
signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper),
|
||||
signature.thisType && instantiateType(signature.thisType, mapper),
|
||||
instantiateList(signature.parameters, mapper, instantiateSymbol),
|
||||
instantiateType(signature.resolvedReturnType, mapper),
|
||||
@@ -17156,6 +17168,15 @@ namespace ts {
|
||||
return getSymbolOfEntityNameOrPropertyAccessExpression(<EntityName | PropertyAccessExpression>node);
|
||||
|
||||
case SyntaxKind.ThisKeyword:
|
||||
const container = getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
if (isFunctionLike(container)) {
|
||||
const sig = getSignatureFromDeclaration(container);
|
||||
if (sig.thisParameter) {
|
||||
return sig.thisParameter;
|
||||
}
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case SyntaxKind.SuperKeyword:
|
||||
const type = isExpression(node) ? checkExpression(<Expression>node) : getTypeFromTypeNode(<TypeNode>node);
|
||||
return type.symbol;
|
||||
|
||||
@@ -2388,6 +2388,8 @@ namespace ts {
|
||||
parameters: Symbol[]; // Parameters
|
||||
thisType?: Type; // type of this-type
|
||||
/* @internal */
|
||||
thisParameter?: Symbol; // symbol of this-type parameter
|
||||
/* @internal */
|
||||
resolvedReturnType: Type; // Resolved return type
|
||||
/* @internal */
|
||||
minArgumentCount: number; // Number of non-optional parameters
|
||||
|
||||
@@ -779,6 +779,7 @@ namespace ts {
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
thisParameter: Symbol;
|
||||
thisType: Type;
|
||||
resolvedReturnType: Type;
|
||||
minArgumentCount: number;
|
||||
@@ -8069,26 +8070,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.kind === SyntaxKind.ThisKeyword) {
|
||||
const container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
|
||||
// Only allow rename to change a function with a 'this' type to one with a regular parameter,
|
||||
// e.g. `function(this: number) { return this; }` to `function(x: number) { return x; }`
|
||||
if (isFunctionLike(container)) {
|
||||
const sig = typeChecker.getSignatureFromDeclaration(container);
|
||||
if (sig.thisType) {
|
||||
return {
|
||||
canRename: true,
|
||||
kind: ScriptElementKind.parameterElement,
|
||||
displayName: "this",
|
||||
localizedErrorMessage: undefined,
|
||||
fullDisplayName: "this",
|
||||
kindModifiers: "",
|
||||
triggerSpan: createTriggerSpanForNode(node, sourceFile)
|
||||
};
|
||||
}
|
||||
}
|
||||
// fallthrough to error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ function weird(this: Example, a = this.getNumber()) {
|
||||
>Example : Symbol(Example, Decl(inferParameterWithMethodCallInitializer.ts, 2, 1))
|
||||
>a : Symbol(a, Decl(inferParameterWithMethodCallInitializer.ts, 11, 29))
|
||||
>this.getNumber : Symbol(Example.getNumber, Decl(inferParameterWithMethodCallInitializer.ts, 3, 15))
|
||||
>this : Symbol(Example, Decl(inferParameterWithMethodCallInitializer.ts, 2, 1))
|
||||
>this : Symbol(this, Decl(inferParameterWithMethodCallInitializer.ts, 11, 15))
|
||||
>getNumber : Symbol(Example.getNumber, Decl(inferParameterWithMethodCallInitializer.ts, 3, 15))
|
||||
|
||||
return a;
|
||||
@@ -45,7 +45,7 @@ class Weird {
|
||||
>Example : Symbol(Example, Decl(inferParameterWithMethodCallInitializer.ts, 2, 1))
|
||||
>a : Symbol(a, Decl(inferParameterWithMethodCallInitializer.ts, 15, 30))
|
||||
>this.getNumber : Symbol(Example.getNumber, Decl(inferParameterWithMethodCallInitializer.ts, 3, 15))
|
||||
>this : Symbol(Example, Decl(inferParameterWithMethodCallInitializer.ts, 2, 1))
|
||||
>this : Symbol(this, Decl(inferParameterWithMethodCallInitializer.ts, 15, 16))
|
||||
>getNumber : Symbol(Example.getNumber, Decl(inferParameterWithMethodCallInitializer.ts, 3, 15))
|
||||
|
||||
return a;
|
||||
|
||||
@@ -20,7 +20,7 @@ const explicit = {
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 7, 10))
|
||||
>Foo : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 7, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
|
||||
set x(this: Foo, n: number) { this.n = n; }
|
||||
@@ -29,7 +29,7 @@ const explicit = {
|
||||
>Foo : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 8, 20))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 8, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 8, 20))
|
||||
}
|
||||
@@ -44,14 +44,14 @@ const copiedFromGetter = {
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 12, 10))
|
||||
>Foo : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 12, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
|
||||
set x(n) { this.n = n; }
|
||||
>x : Symbol(x, Decl(thisTypeInAccessors.ts, 11, 10), Decl(thisTypeInAccessors.ts, 12, 48))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 13, 10))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 12, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 13, 10))
|
||||
}
|
||||
@@ -64,7 +64,7 @@ const copiedFromSetter = {
|
||||
get x() { return this.n },
|
||||
>x : Symbol(x, Decl(thisTypeInAccessors.ts, 16, 10), Decl(thisTypeInAccessors.ts, 17, 30))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 18, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
|
||||
set x(this: Foo, n: number) { this.n = n; }
|
||||
@@ -73,7 +73,7 @@ const copiedFromSetter = {
|
||||
>Foo : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 18, 20))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 18, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 18, 20))
|
||||
}
|
||||
@@ -88,7 +88,7 @@ const copiedFromGetterUnannotated = {
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 22, 10))
|
||||
>Foo : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 22, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
|
||||
set x(this, n) { this.n = n; }
|
||||
@@ -96,7 +96,7 @@ const copiedFromGetterUnannotated = {
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 23, 10))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 23, 15))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 22, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 23, 15))
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class Explicit {
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 28, 10))
|
||||
>Foo : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 28, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
|
||||
set x(this: Foo, n: number) { this.n = n; }
|
||||
@@ -121,7 +121,7 @@ class Explicit {
|
||||
>Foo : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 29, 20))
|
||||
>this.n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>this : Symbol(Foo, Decl(thisTypeInAccessors.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInAccessors.ts, 29, 10))
|
||||
>n : Symbol(Foo.n, Decl(thisTypeInAccessors.ts, 0, 15))
|
||||
>n : Symbol(n, Decl(thisTypeInAccessors.ts, 29, 20))
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class C {
|
||||
|
||||
return this.n + m;
|
||||
>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 6, 17))
|
||||
>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 28))
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class C {
|
||||
|
||||
return this.n + m;
|
||||
>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 9, 14))
|
||||
>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22))
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class C {
|
||||
|
||||
return this.n + m;
|
||||
>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28))
|
||||
>this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 21))
|
||||
>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39))
|
||||
}
|
||||
@@ -97,7 +97,7 @@ function explicitStructural(this: { y: number }, x: number): number {
|
||||
return x + this.y;
|
||||
>x : Symbol(x, Decl(thisTypeInFunctions.ts, 28, 48))
|
||||
>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 28, 35))
|
||||
>this : Symbol(, Decl(thisTypeInFunctions.ts, 28, 33))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 28, 28))
|
||||
>y : Symbol(y, Decl(thisTypeInFunctions.ts, 28, 35))
|
||||
}
|
||||
function justThis(this: { y: number }): number {
|
||||
@@ -107,7 +107,7 @@ function justThis(this: { y: number }): number {
|
||||
|
||||
return this.y;
|
||||
>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 31, 25))
|
||||
>this : Symbol(, Decl(thisTypeInFunctions.ts, 31, 23))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 31, 18))
|
||||
>y : Symbol(y, Decl(thisTypeInFunctions.ts, 31, 25))
|
||||
}
|
||||
function implicitThis(n: number): number {
|
||||
@@ -435,7 +435,7 @@ c.explicitC = function(this: C, m: number) { return this.n + m };
|
||||
>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 105, 31))
|
||||
>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 105, 23))
|
||||
>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 105, 31))
|
||||
|
||||
@@ -453,7 +453,7 @@ c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m
|
||||
>n : Symbol(n, Decl(thisTypeInFunctions.ts, 107, 37))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 107, 48))
|
||||
>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 107, 37))
|
||||
>this : Symbol(, Decl(thisTypeInFunctions.ts, 107, 35))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 107, 30))
|
||||
>n : Symbol(n, Decl(thisTypeInFunctions.ts, 107, 37))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 107, 48))
|
||||
|
||||
@@ -525,7 +525,7 @@ c.explicitThis = function(this: C, m: number) { return this.n + m };
|
||||
>C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 123, 34))
|
||||
>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 123, 26))
|
||||
>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 123, 34))
|
||||
|
||||
@@ -568,7 +568,7 @@ c.explicitThis = function(this, m) { return this.n + m };
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 131, 26))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 131, 31))
|
||||
>this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 131, 26))
|
||||
>n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 131, 31))
|
||||
|
||||
@@ -581,7 +581,7 @@ c.explicitC = function(this: B, m: number) { return this.n + m };
|
||||
>B : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 31))
|
||||
>this.n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9))
|
||||
>this : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 134, 23))
|
||||
>n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9))
|
||||
>m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 31))
|
||||
|
||||
@@ -604,7 +604,7 @@ class Base1 {
|
||||
>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 141, 14))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 142, 23))
|
||||
>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13))
|
||||
>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 142, 23))
|
||||
>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13))
|
||||
|
||||
explicit(this: Base1): number { return this.x; }
|
||||
@@ -612,7 +612,7 @@ class Base1 {
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 143, 13))
|
||||
>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24))
|
||||
>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13))
|
||||
>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 143, 13))
|
||||
>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13))
|
||||
|
||||
static explicitStatic(this: typeof Base1): number { return this.y; }
|
||||
@@ -620,7 +620,7 @@ class Base1 {
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 144, 26))
|
||||
>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24))
|
||||
>this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 144, 72))
|
||||
>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 144, 26))
|
||||
>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 144, 72))
|
||||
|
||||
static y: number;
|
||||
@@ -643,7 +643,7 @@ class Base2 {
|
||||
>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 151, 13))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 152, 16))
|
||||
>this.y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 150, 13))
|
||||
>this : Symbol(Base2, Decl(thisTypeInFunctions.ts, 149, 1))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 152, 16))
|
||||
>y : Symbol(Base2.y, Decl(thisTypeInFunctions.ts, 150, 13))
|
||||
|
||||
explicit(this: Base1): number { return this.x; }
|
||||
@@ -651,7 +651,7 @@ class Base2 {
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 153, 13))
|
||||
>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24))
|
||||
>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13))
|
||||
>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 137, 24))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 153, 13))
|
||||
>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 140, 13))
|
||||
}
|
||||
class Derived2 extends Base2 {
|
||||
@@ -734,7 +734,7 @@ function InterfaceThis(this: I) {
|
||||
|
||||
this.a = 12;
|
||||
>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13))
|
||||
>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 172, 23))
|
||||
>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13))
|
||||
}
|
||||
function LiteralTypeThis(this: {x: string}) {
|
||||
@@ -744,7 +744,7 @@ function LiteralTypeThis(this: {x: string}) {
|
||||
|
||||
this.x = "ok";
|
||||
>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 175, 32))
|
||||
>this : Symbol(, Decl(thisTypeInFunctions.ts, 175, 30))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 175, 25))
|
||||
>x : Symbol(x, Decl(thisTypeInFunctions.ts, 175, 32))
|
||||
}
|
||||
function AnyThis(this: any) {
|
||||
@@ -752,6 +752,7 @@ function AnyThis(this: any) {
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 178, 17))
|
||||
|
||||
this.x = "ok";
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 178, 17))
|
||||
}
|
||||
let interfaceThis = new InterfaceThis();
|
||||
>interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 181, 3))
|
||||
@@ -793,5 +794,6 @@ function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; }
|
||||
>missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 190, 27))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 192, 34))
|
||||
>a : Symbol(a, Decl(thisTypeInFunctions.ts, 192, 39))
|
||||
>this : Symbol(this, Decl(thisTypeInFunctions.ts, 192, 34))
|
||||
>a : Symbol(a, Decl(thisTypeInFunctions.ts, 192, 39))
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @noLib: true
|
||||
////function f(/*fnDecl*/this: number) {
|
||||
//// return /*fnUse*/this;
|
||||
////}
|
||||
/////*cls*/class C {
|
||||
//// constructor() { return /*clsUse*/this; }
|
||||
//// get self(/*getterDecl*/this: number) { return /*getterUse*/this; }
|
||||
////}
|
||||
|
||||
function verifyDefinition(a, b) {
|
||||
goTo.marker(a);
|
||||
goTo.definition();
|
||||
verify.caretAtMarker(b);
|
||||
}
|
||||
|
||||
verifyDefinition("fnUse", "fnDecl");
|
||||
verifyDefinition("clsUse", "cls");
|
||||
verifyDefinition("getterUse", "getterDecl");
|
||||
@@ -25,7 +25,7 @@
|
||||
goTo.marker('0');
|
||||
verify.quickInfoIs('this: this');
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs('void');
|
||||
verify.quickInfoIs('this: void');
|
||||
goTo.marker('2');
|
||||
verify.quickInfoIs('this: this');
|
||||
goTo.marker('3');
|
||||
|
||||
@@ -20,7 +20,7 @@ verify.quickInfoIs('any');
|
||||
goTo.marker('2');
|
||||
verify.quickInfoIs('(parameter) this: void');
|
||||
goTo.marker('3');
|
||||
verify.quickInfoIs('void');
|
||||
verify.quickInfoIs('this: void');
|
||||
goTo.marker('4');
|
||||
verify.quickInfoIs('(parameter) this: Restricted');
|
||||
goTo.marker('5');
|
||||
|
||||
@@ -12,7 +12,7 @@ for (let range of [r0, r1]) {
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false, [r0, r1]);
|
||||
}
|
||||
|
||||
// Trying to rename a legitimate 'this' should fail
|
||||
// Trying to rename a non-parameter 'this' should fail
|
||||
goTo.marker();
|
||||
verify.renameInfoFailed("You cannot rename this element.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user