Add regression test

This commit is contained in:
Anders Hejlsberg
2017-11-02 14:48:34 -07:00
parent 6911acf80b
commit 18b5ade05d
4 changed files with 73 additions and 0 deletions
@@ -0,0 +1,13 @@
//// [freshLiteralTypesInIntersections.ts]
// Repro from #19657
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
const q = func("x" as "x" | "y", ["x"]);
q("x");
//// [freshLiteralTypesInIntersections.js]
"use strict";
// Repro from #19657
var q = func("x", ["x"]);
q("x");
@@ -0,0 +1,23 @@
=== tests/cases/compiler/freshLiteralTypesInIntersections.ts ===
// Repro from #19657
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
>func : Symbol(func, Decl(freshLiteralTypesInIntersections.ts, 0, 0))
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
>B : Symbol(B, Decl(freshLiteralTypesInIntersections.ts, 2, 39))
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
>a : Symbol(a, Decl(freshLiteralTypesInIntersections.ts, 2, 53))
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
>b : Symbol(b, Decl(freshLiteralTypesInIntersections.ts, 2, 58))
>B : Symbol(B, Decl(freshLiteralTypesInIntersections.ts, 2, 39))
>ab : Symbol(ab, Decl(freshLiteralTypesInIntersections.ts, 2, 69))
>A : Symbol(A, Decl(freshLiteralTypesInIntersections.ts, 2, 22))
>B : Symbol(B, Decl(freshLiteralTypesInIntersections.ts, 2, 39))
const q = func("x" as "x" | "y", ["x"]);
>q : Symbol(q, Decl(freshLiteralTypesInIntersections.ts, 3, 5))
>func : Symbol(func, Decl(freshLiteralTypesInIntersections.ts, 0, 0))
q("x");
>q : Symbol(q, Decl(freshLiteralTypesInIntersections.ts, 3, 5))
@@ -0,0 +1,30 @@
=== tests/cases/compiler/freshLiteralTypesInIntersections.ts ===
// Repro from #19657
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
>func : <A extends string, B extends A>(a: A, b: B[]) => (ab: A & B) => void
>A : A
>B : B
>A : A
>a : A
>A : A
>b : B[]
>B : B
>ab : A & B
>A : A
>B : B
const q = func("x" as "x" | "y", ["x"]);
>q : (ab: "x") => void
>func("x" as "x" | "y", ["x"]) : (ab: "x") => void
>func : <A extends string, B extends A>(a: A, b: B[]) => (ab: A & B) => void
>"x" as "x" | "y" : "x" | "y"
>"x" : "x"
>["x"] : "x"[]
>"x" : "x"
q("x");
>q("x") : void
>q : (ab: "x") => void
>"x" : "x"
@@ -0,0 +1,7 @@
// @strict: true
// Repro from #19657
declare function func<A extends string, B extends A>(a: A, b: B[]): (ab: A & B) => void;
const q = func("x" as "x" | "y", ["x"]);
q("x");