From 3531bd2b570d0ca95276fd78fd8e6217a90c3b4b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 1 Dec 2017 16:54:32 -0800 Subject: [PATCH] Add regression test --- .../functionCallOnConstrainedTypeVariable.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts diff --git a/tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts b/tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts new file mode 100644 index 0000000000..8ceb578dc0 --- /dev/null +++ b/tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts @@ -0,0 +1,22 @@ +// @strict: true + +// Repro from #20196 + +type A = { + a: (x: number) => string +}; +type B = { + a: (x: boolean) => string +}; + +function call0(p: A | B) { + p.a("s"); // Error +} + +function callN(p: T) { + p.a("s"); // Error + + var a: T["a"] = p.a; + a(""); // Error + a("", "", "", ""); // Error +} \ No newline at end of file