Add method signature handler to getTypeOfVariableOrParameterOrProperty (#20825)

This commit is contained in:
Wesley Wigham 2017-12-28 19:00:54 -08:00 committed by GitHub
parent 196f1c2086
commit ae211983eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 1 deletions

View file

@ -4683,7 +4683,8 @@ namespace ts {
else if (isJSDocPropertyTag(declaration)
|| isPropertyAccessExpression(declaration)
|| isIdentifier(declaration)
|| isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration)) {
|| (isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration))
|| isMethodSignature(declaration)) {
// TODO: Mimics old behavior from incorrect usage of getWidenedTypeForVariableLikeDeclaration, but seems incorrect
type = tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
}

View file

@ -0,0 +1,12 @@
//// [methodSignatureHandledDeclarationKindForSymbol.ts]
interface Foo {
bold(): string;
}
interface Foo {
bold: string;
}
//// [methodSignatureHandledDeclarationKindForSymbol.js]

View file

@ -0,0 +1,16 @@
=== tests/cases/compiler/methodSignatureHandledDeclarationKindForSymbol.ts ===
interface Foo {
>Foo : Symbol(Foo, Decl(methodSignatureHandledDeclarationKindForSymbol.ts, 0, 0), Decl(methodSignatureHandledDeclarationKindForSymbol.ts, 2, 1))
bold(): string;
>bold : Symbol(Foo.bold, Decl(methodSignatureHandledDeclarationKindForSymbol.ts, 0, 15), Decl(methodSignatureHandledDeclarationKindForSymbol.ts, 4, 15))
}
interface Foo {
>Foo : Symbol(Foo, Decl(methodSignatureHandledDeclarationKindForSymbol.ts, 0, 0), Decl(methodSignatureHandledDeclarationKindForSymbol.ts, 2, 1))
bold: string;
>bold : Symbol(Foo.bold, Decl(methodSignatureHandledDeclarationKindForSymbol.ts, 0, 15), Decl(methodSignatureHandledDeclarationKindForSymbol.ts, 4, 15))
}

View file

@ -0,0 +1,16 @@
=== tests/cases/compiler/methodSignatureHandledDeclarationKindForSymbol.ts ===
interface Foo {
>Foo : Foo
bold(): string;
>bold : string
}
interface Foo {
>Foo : Foo
bold: string;
>bold : string
}

View file

@ -0,0 +1,8 @@
interface Foo {
bold(): string;
}
interface Foo {
bold: string;
}