diff --git a/tests/cases/conformance/types/literal/literalTypeWidening.ts b/tests/cases/conformance/types/literal/literalTypeWidening.ts index 98ed328f0d2..4c818793142 100644 --- a/tests/cases/conformance/types/literal/literalTypeWidening.ts +++ b/tests/cases/conformance/types/literal/literalTypeWidening.ts @@ -59,6 +59,18 @@ function f5() { let v4 = c4; } +declare function widening(x: T): T; +declare function nonWidening(x: T): T; + +function f6(cond: boolean) { + let x1 = widening('a'); + let x2 = widening(10); + let x3 = widening(cond ? 'a' : 10); + let y1 = nonWidening('a'); + let y2 = nonWidening(10); + let y3 = nonWidening(cond ? 'a' : 10); +} + // Repro from #10898 type FAILURE = "FAILURE"; @@ -94,4 +106,24 @@ type TestEvent = "onmouseover" | "onmouseout"; function onMouseOver(): TestEvent { return "onmouseover"; } -let x = onMouseOver(); \ No newline at end of file +let x = onMouseOver(); + +// Repro from #23649 + +export function Set(...keys: K[]): Record { + const result = {} as Record + keys.forEach(key => result[key] = true) + return result +} + +export function keys(obj: Record): K[] { + return Object.keys(obj) as K[] +} + +type Obj = { code: LangCode } + +const langCodeSet = Set('fr', 'en', 'es', 'it', 'nl') +export type LangCode = keyof typeof langCodeSet +export const langCodes = keys(langCodeSet) + +const arr: Obj[] = langCodes.map(code => ({ code }))