From 1e55d650f3dd8c768158c5a2bcde1ebf95b590a8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 2 Oct 2018 09:41:06 -0700 Subject: [PATCH] Exclude the overlap between Type and Value when checking for parameter visibility (#27444) --- src/compiler/checker.ts | 2 +- .../reference/typeParameterDoesntBlockParameterLookup.js | 4 ++++ .../typeParameterDoesntBlockParameterLookup.symbols | 8 ++++++++ .../typeParameterDoesntBlockParameterLookup.types | 5 +++++ .../compiler/typeParameterDoesntBlockParameterLookup.ts | 1 + 5 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/typeParameterDoesntBlockParameterLookup.js create mode 100644 tests/baselines/reference/typeParameterDoesntBlockParameterLookup.symbols create mode 100644 tests/baselines/reference/typeParameterDoesntBlockParameterLookup.types create mode 100644 tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6210ebcfbf8..82480428790 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1238,7 +1238,7 @@ namespace ts { // local types not visible outside the function body : false; } - if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.FunctionScopedVariable) { + if (meaning & result.flags & SymbolFlags.FunctionScopedVariable) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters diff --git a/tests/baselines/reference/typeParameterDoesntBlockParameterLookup.js b/tests/baselines/reference/typeParameterDoesntBlockParameterLookup.js new file mode 100644 index 00000000000..90f1a1f4a37 --- /dev/null +++ b/tests/baselines/reference/typeParameterDoesntBlockParameterLookup.js @@ -0,0 +1,4 @@ +//// [typeParameterDoesntBlockParameterLookup.ts] +declare function f(Bar: any): void + +//// [typeParameterDoesntBlockParameterLookup.js] diff --git a/tests/baselines/reference/typeParameterDoesntBlockParameterLookup.symbols b/tests/baselines/reference/typeParameterDoesntBlockParameterLookup.symbols new file mode 100644 index 00000000000..8c98b05e2dd --- /dev/null +++ b/tests/baselines/reference/typeParameterDoesntBlockParameterLookup.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts === +declare function f(Bar: any): void +>f : Symbol(f, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 19)) +>Bar : Symbol(Bar, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 35), Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 41)) +>Bar : Symbol(Bar, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 35), Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 41)) +>Bar : Symbol(Bar, Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 35), Decl(typeParameterDoesntBlockParameterLookup.ts, 0, 41)) + diff --git a/tests/baselines/reference/typeParameterDoesntBlockParameterLookup.types b/tests/baselines/reference/typeParameterDoesntBlockParameterLookup.types new file mode 100644 index 00000000000..7edcbde4373 --- /dev/null +++ b/tests/baselines/reference/typeParameterDoesntBlockParameterLookup.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts === +declare function f(Bar: any): void +>f : (Bar: any) => void +>Bar : any + diff --git a/tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts b/tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts new file mode 100644 index 00000000000..20db3123690 --- /dev/null +++ b/tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts @@ -0,0 +1 @@ +declare function f(Bar: any): void \ No newline at end of file