Add method signature handler to getTypeOfVariableOrParameterOrProperty (#20825)
This commit is contained in:
parent
196f1c2086
commit
ae211983eb
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
//// [methodSignatureHandledDeclarationKindForSymbol.ts]
|
||||
interface Foo {
|
||||
bold(): string;
|
||||
}
|
||||
|
||||
interface Foo {
|
||||
bold: string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [methodSignatureHandledDeclarationKindForSymbol.js]
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
interface Foo {
|
||||
bold(): string;
|
||||
}
|
||||
|
||||
interface Foo {
|
||||
bold: string;
|
||||
}
|
||||
|
Loading…
Reference in a new issue