mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
fix type lookup rule
This commit is contained in:
parent
dcbc478efa
commit
9b7e5e212f
@ -1234,7 +1234,7 @@ namespace ts {
|
||||
lastLocation.kind === SyntaxKind.Parameter ||
|
||||
(
|
||||
lastLocation === (<FunctionLikeDeclaration>location).type &&
|
||||
result.valueDeclaration.kind === SyntaxKind.Parameter
|
||||
!!findAncestor(result.valueDeclaration, isParameter)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
7
tests/baselines/reference/functionReturnTypeQuery.js
Normal file
7
tests/baselines/reference/functionReturnTypeQuery.js
Normal file
@ -0,0 +1,7 @@
|
||||
//// [functionReturnTypeQuery.ts]
|
||||
declare let foo: number;
|
||||
|
||||
declare function test1(foo: string, bar: typeof foo): typeof foo;
|
||||
declare function test2({foo}: {foo: string}, bar: typeof foo): typeof foo;
|
||||
|
||||
//// [functionReturnTypeQuery.js]
|
||||
19
tests/baselines/reference/functionReturnTypeQuery.symbols
Normal file
19
tests/baselines/reference/functionReturnTypeQuery.symbols
Normal file
@ -0,0 +1,19 @@
|
||||
=== tests/cases/compiler/functionReturnTypeQuery.ts ===
|
||||
declare let foo: number;
|
||||
>foo : Symbol(foo, Decl(functionReturnTypeQuery.ts, 0, 11))
|
||||
|
||||
declare function test1(foo: string, bar: typeof foo): typeof foo;
|
||||
>test1 : Symbol(test1, Decl(functionReturnTypeQuery.ts, 0, 24))
|
||||
>foo : Symbol(foo, Decl(functionReturnTypeQuery.ts, 2, 23))
|
||||
>bar : Symbol(bar, Decl(functionReturnTypeQuery.ts, 2, 35))
|
||||
>foo : Symbol(foo, Decl(functionReturnTypeQuery.ts, 2, 23))
|
||||
>foo : Symbol(foo, Decl(functionReturnTypeQuery.ts, 2, 23))
|
||||
|
||||
declare function test2({foo}: {foo: string}, bar: typeof foo): typeof foo;
|
||||
>test2 : Symbol(test2, Decl(functionReturnTypeQuery.ts, 2, 65))
|
||||
>foo : Symbol(foo, Decl(functionReturnTypeQuery.ts, 3, 24))
|
||||
>foo : Symbol(foo, Decl(functionReturnTypeQuery.ts, 3, 31))
|
||||
>bar : Symbol(bar, Decl(functionReturnTypeQuery.ts, 3, 44))
|
||||
>foo : Symbol(foo, Decl(functionReturnTypeQuery.ts, 3, 24))
|
||||
>foo : Symbol(foo, Decl(functionReturnTypeQuery.ts, 3, 24))
|
||||
|
||||
19
tests/baselines/reference/functionReturnTypeQuery.types
Normal file
19
tests/baselines/reference/functionReturnTypeQuery.types
Normal file
@ -0,0 +1,19 @@
|
||||
=== tests/cases/compiler/functionReturnTypeQuery.ts ===
|
||||
declare let foo: number;
|
||||
>foo : number
|
||||
|
||||
declare function test1(foo: string, bar: typeof foo): typeof foo;
|
||||
>test1 : (foo: string, bar: string) => string
|
||||
>foo : string
|
||||
>bar : string
|
||||
>foo : string
|
||||
>foo : string
|
||||
|
||||
declare function test2({foo}: {foo: string}, bar: typeof foo): typeof foo;
|
||||
>test2 : ({ foo }: { foo: string; }, bar: string) => string
|
||||
>foo : string
|
||||
>foo : string
|
||||
>bar : string
|
||||
>foo : string
|
||||
>foo : string
|
||||
|
||||
@ -312,6 +312,7 @@ function b5({a, b, p1}, p2, p3): p1 is A {
|
||||
>p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 127, 18))
|
||||
>p2 : Symbol(p2, Decl(typeGuardFunctionErrors.ts, 127, 23))
|
||||
>p3 : Symbol(p3, Decl(typeGuardFunctionErrors.ts, 127, 27))
|
||||
>p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 127, 18))
|
||||
>A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0))
|
||||
|
||||
return true;
|
||||
@ -324,6 +325,7 @@ function b6([a, b, p1], p2, p3): p1 is A {
|
||||
>p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 131, 18))
|
||||
>p2 : Symbol(p2, Decl(typeGuardFunctionErrors.ts, 131, 23))
|
||||
>p3 : Symbol(p3, Decl(typeGuardFunctionErrors.ts, 131, 27))
|
||||
>p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 131, 18))
|
||||
>A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0))
|
||||
|
||||
return true;
|
||||
@ -337,6 +339,7 @@ function b7({a, b, c: {p1}}, p2, p3): p1 is A {
|
||||
>p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 135, 23))
|
||||
>p2 : Symbol(p2, Decl(typeGuardFunctionErrors.ts, 135, 28))
|
||||
>p3 : Symbol(p3, Decl(typeGuardFunctionErrors.ts, 135, 32))
|
||||
>p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 135, 23))
|
||||
>A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0))
|
||||
|
||||
return true;
|
||||
|
||||
@ -356,7 +356,7 @@ function b5({a, b, p1}, p2, p3): p1 is A {
|
||||
>p1 : any
|
||||
>p2 : any
|
||||
>p3 : any
|
||||
>p1 : No type information available!
|
||||
>p1 : any
|
||||
>A : A
|
||||
|
||||
return true;
|
||||
@ -370,7 +370,7 @@ function b6([a, b, p1], p2, p3): p1 is A {
|
||||
>p1 : any
|
||||
>p2 : any
|
||||
>p3 : any
|
||||
>p1 : No type information available!
|
||||
>p1 : any
|
||||
>A : A
|
||||
|
||||
return true;
|
||||
@ -385,7 +385,7 @@ function b7({a, b, c: {p1}}, p2, p3): p1 is A {
|
||||
>p1 : any
|
||||
>p2 : any
|
||||
>p3 : any
|
||||
>p1 : No type information available!
|
||||
>p1 : any
|
||||
>A : A
|
||||
|
||||
return true;
|
||||
|
||||
4
tests/cases/compiler/functionReturnTypeQuery.ts
Normal file
4
tests/cases/compiler/functionReturnTypeQuery.ts
Normal file
@ -0,0 +1,4 @@
|
||||
declare let foo: number;
|
||||
|
||||
declare function test1(foo: string, bar: typeof foo): typeof foo;
|
||||
declare function test2({foo}: {foo: string}, bar: typeof foo): typeof foo;
|
||||
Loading…
x
Reference in New Issue
Block a user