From dd8d9ac86b00f6ef0cb25068f710b0b541ab32c0 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 28 Sep 2018 16:37:30 -0700 Subject: [PATCH] Exclude the overlap between Type and Value when checking for parameter visibility --- 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 611b6c4d4b075..07e82eac0a64b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1231,7 +1231,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 0000000000000..90f1a1f4a379b --- /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 0000000000000..8c98b05e2ddcc --- /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 0000000000000..7edcbde437379 --- /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 0000000000000..20db312369029 --- /dev/null +++ b/tests/cases/compiler/typeParameterDoesntBlockParameterLookup.ts @@ -0,0 +1 @@ +declare function f(Bar: any): void \ No newline at end of file