@@ -59,6 +59,18 @@ function f5() {
5959 let v4 = c4 ;
6060}
6161
62+ declare function widening < T > ( x : T ) : T ;
63+ declare function nonWidening < T extends string | number | symbol > ( x : T ) : T ;
64+
65+ function f6 ( cond : boolean ) {
66+ let x1 = widening ( 'a' ) ;
67+ let x2 = widening ( 10 ) ;
68+ let x3 = widening ( cond ? 'a' : 10 ) ;
69+ let y1 = nonWidening ( 'a' ) ;
70+ let y2 = nonWidening ( 10 ) ;
71+ let y3 = nonWidening ( cond ? 'a' : 10 ) ;
72+ }
73+
6274// Repro from #10898
6375
6476type FAILURE = "FAILURE" ;
@@ -94,4 +106,24 @@ type TestEvent = "onmouseover" | "onmouseout";
94106
95107function onMouseOver ( ) : TestEvent { return "onmouseover" ; }
96108
97- let x = onMouseOver ( ) ;
109+ let x = onMouseOver ( ) ;
110+
111+ // Repro from #23649
112+
113+ export function Set < K extends string > ( ...keys : K [ ] ) : Record < K , true | undefined > {
114+ const result = { } as Record < K , true | undefined >
115+ keys . forEach ( key => result [ key ] = true )
116+ return result
117+ }
118+
119+ export function keys < K extends string , V > ( obj : Record < K , V > ) : K [ ] {
120+ return Object . keys ( obj ) as K [ ]
121+ }
122+
123+ type Obj = { code : LangCode }
124+
125+ const langCodeSet = Set ( 'fr' , 'en' , 'es' , 'it' , 'nl' )
126+ export type LangCode = keyof typeof langCodeSet
127+ export const langCodes = keys ( langCodeSet )
128+
129+ const arr : Obj [ ] = langCodes . map ( code => ( { code } ) )
0 commit comments