Skip to content

Commit 1e55d65

Browse files
authored
Exclude the overlap between Type and Value when checking for parameter visibility (#27444)
1 parent b15d6a4 commit 1e55d65

5 files changed

+19
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ namespace ts {
12381238
// local types not visible outside the function body
12391239
: false;
12401240
}
1241-
if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.FunctionScopedVariable) {
1241+
if (meaning & result.flags & SymbolFlags.FunctionScopedVariable) {
12421242
// parameters are visible only inside function body, parameter list and return type
12431243
// technically for parameter list case here we might mix parameters and variables declared in function,
12441244
// however it is detected separately when checking initializers of parameters
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//// [typeParameterDoesntBlockParameterLookup.ts]
2+
declare function f<Foo extends Bar, Bar>(Bar: any): void
3+
4+
//// [typeParameterDoesntBlockParameterLookup.js]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts ===
2+
declare function f<Foo extends Bar, Bar>(Bar: any): void
3+
>f : Symbol(f, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 0))
4+
>Foo : Symbol(Foo, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 19))
5+
>Bar : Symbol(Bar, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 35), Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 41))
6+
>Bar : Symbol(Bar, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 35), Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 41))
7+
>Bar : Symbol(Bar, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 35), Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 41))
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts ===
2+
declare function f<Foo extends Bar, Bar>(Bar: any): void
3+
>f : <Foo extends Bar, Bar>(Bar: any) => void
4+
>Bar : any
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare function f<Foo extends Bar, Bar>(Bar: any): void

0 commit comments

Comments
 (0)