|
| 1 | +//// [tests/cases/conformance/types/literal/stringMappingReduction.ts] //// |
| 2 | + |
| 3 | +=== stringMappingReduction.ts === |
| 4 | +type T00 = "prop" | `p${Lowercase<string>}p`; // `p${Lowercase<string>}p` |
| 5 | +>T00 : Symbol(T00, Decl(stringMappingReduction.ts, 0, 0)) |
| 6 | +>Lowercase : Symbol(Lowercase, Decl(lib.es5.d.ts, --, --)) |
| 7 | + |
| 8 | +type T01 = "prop" | Lowercase<string>; // Lowercase<string> |
| 9 | +>T01 : Symbol(T01, Decl(stringMappingReduction.ts, 0, 45)) |
| 10 | +>Lowercase : Symbol(Lowercase, Decl(lib.es5.d.ts, --, --)) |
| 11 | + |
| 12 | +type T02 = "PROP" | Lowercase<string>; // "PROP" | Lowercase<string> |
| 13 | +>T02 : Symbol(T02, Decl(stringMappingReduction.ts, 1, 38)) |
| 14 | +>Lowercase : Symbol(Lowercase, Decl(lib.es5.d.ts, --, --)) |
| 15 | + |
| 16 | +type T10 = "prop" & `p${Lowercase<string>}p`; // "prop" |
| 17 | +>T10 : Symbol(T10, Decl(stringMappingReduction.ts, 2, 38)) |
| 18 | +>Lowercase : Symbol(Lowercase, Decl(lib.es5.d.ts, --, --)) |
| 19 | + |
| 20 | +type T11 = "prop" & Lowercase<string>; // "prop" |
| 21 | +>T11 : Symbol(T11, Decl(stringMappingReduction.ts, 4, 45)) |
| 22 | +>Lowercase : Symbol(Lowercase, Decl(lib.es5.d.ts, --, --)) |
| 23 | + |
| 24 | +type T12 = "PROP" & Lowercase<string>; // never |
| 25 | +>T12 : Symbol(T12, Decl(stringMappingReduction.ts, 5, 38)) |
| 26 | +>Lowercase : Symbol(Lowercase, Decl(lib.es5.d.ts, --, --)) |
| 27 | + |
| 28 | +type T20 = "prop" | Capitalize<string>; // "prop" | Capitalize<string> |
| 29 | +>T20 : Symbol(T20, Decl(stringMappingReduction.ts, 6, 38)) |
| 30 | +>Capitalize : Symbol(Capitalize, Decl(lib.es5.d.ts, --, --)) |
| 31 | + |
| 32 | +type T21 = "Prop" | Capitalize<string>; // Capitalize<string> |
| 33 | +>T21 : Symbol(T21, Decl(stringMappingReduction.ts, 8, 39)) |
| 34 | +>Capitalize : Symbol(Capitalize, Decl(lib.es5.d.ts, --, --)) |
| 35 | + |
| 36 | +type T22 = "PROP" | Capitalize<string>; // Capitalize<string> |
| 37 | +>T22 : Symbol(T22, Decl(stringMappingReduction.ts, 9, 39)) |
| 38 | +>Capitalize : Symbol(Capitalize, Decl(lib.es5.d.ts, --, --)) |
| 39 | + |
| 40 | +type T30 = "prop" & Capitalize<string>; // never |
| 41 | +>T30 : Symbol(T30, Decl(stringMappingReduction.ts, 10, 39)) |
| 42 | +>Capitalize : Symbol(Capitalize, Decl(lib.es5.d.ts, --, --)) |
| 43 | + |
| 44 | +type T31 = "Prop" & Capitalize<string>; // "Prop" |
| 45 | +>T31 : Symbol(T31, Decl(stringMappingReduction.ts, 12, 39)) |
| 46 | +>Capitalize : Symbol(Capitalize, Decl(lib.es5.d.ts, --, --)) |
| 47 | + |
| 48 | +type T32 = "PROP" & Capitalize<string>; // "PROP" |
| 49 | +>T32 : Symbol(T32, Decl(stringMappingReduction.ts, 13, 39)) |
| 50 | +>Capitalize : Symbol(Capitalize, Decl(lib.es5.d.ts, --, --)) |
| 51 | + |
| 52 | +// Repro from #57117 |
| 53 | + |
| 54 | +type EMap = { event: {} } |
| 55 | +>EMap : Symbol(EMap, Decl(stringMappingReduction.ts, 14, 39)) |
| 56 | +>event : Symbol(event, Decl(stringMappingReduction.ts, 18, 13)) |
| 57 | + |
| 58 | +type Keys = keyof EMap |
| 59 | +>Keys : Symbol(Keys, Decl(stringMappingReduction.ts, 18, 25)) |
| 60 | +>EMap : Symbol(EMap, Decl(stringMappingReduction.ts, 14, 39)) |
| 61 | + |
| 62 | +type EPlusFallback<C> = C extends Keys ? EMap[C] : "unrecognised event"; |
| 63 | +>EPlusFallback : Symbol(EPlusFallback, Decl(stringMappingReduction.ts, 19, 22)) |
| 64 | +>C : Symbol(C, Decl(stringMappingReduction.ts, 20, 19)) |
| 65 | +>C : Symbol(C, Decl(stringMappingReduction.ts, 20, 19)) |
| 66 | +>Keys : Symbol(Keys, Decl(stringMappingReduction.ts, 18, 25)) |
| 67 | +>EMap : Symbol(EMap, Decl(stringMappingReduction.ts, 14, 39)) |
| 68 | +>C : Symbol(C, Decl(stringMappingReduction.ts, 20, 19)) |
| 69 | + |
| 70 | +type VirtualEvent<T extends string> = { bivarianceHack(event: EPlusFallback<Lowercase<T>>): any; }['bivarianceHack']; |
| 71 | +>VirtualEvent : Symbol(VirtualEvent, Decl(stringMappingReduction.ts, 20, 72)) |
| 72 | +>T : Symbol(T, Decl(stringMappingReduction.ts, 21, 18)) |
| 73 | +>bivarianceHack : Symbol(bivarianceHack, Decl(stringMappingReduction.ts, 21, 39)) |
| 74 | +>event : Symbol(event, Decl(stringMappingReduction.ts, 21, 55)) |
| 75 | +>EPlusFallback : Symbol(EPlusFallback, Decl(stringMappingReduction.ts, 19, 22)) |
| 76 | +>Lowercase : Symbol(Lowercase, Decl(lib.es5.d.ts, --, --)) |
| 77 | +>T : Symbol(T, Decl(stringMappingReduction.ts, 21, 18)) |
| 78 | + |
| 79 | +declare const _virtualOn: (eventQrl: VirtualEvent<Keys>) => void; |
| 80 | +>_virtualOn : Symbol(_virtualOn, Decl(stringMappingReduction.ts, 22, 13)) |
| 81 | +>eventQrl : Symbol(eventQrl, Decl(stringMappingReduction.ts, 22, 27)) |
| 82 | +>VirtualEvent : Symbol(VirtualEvent, Decl(stringMappingReduction.ts, 20, 72)) |
| 83 | +>Keys : Symbol(Keys, Decl(stringMappingReduction.ts, 18, 25)) |
| 84 | + |
| 85 | +export const virtualOn = <T extends string>(eventQrl: VirtualEvent<T>) => { |
| 86 | +>virtualOn : Symbol(virtualOn, Decl(stringMappingReduction.ts, 23, 12)) |
| 87 | +>T : Symbol(T, Decl(stringMappingReduction.ts, 23, 26)) |
| 88 | +>eventQrl : Symbol(eventQrl, Decl(stringMappingReduction.ts, 23, 44)) |
| 89 | +>VirtualEvent : Symbol(VirtualEvent, Decl(stringMappingReduction.ts, 20, 72)) |
| 90 | +>T : Symbol(T, Decl(stringMappingReduction.ts, 23, 26)) |
| 91 | + |
| 92 | + _virtualOn(eventQrl); |
| 93 | +>_virtualOn : Symbol(_virtualOn, Decl(stringMappingReduction.ts, 22, 13)) |
| 94 | +>eventQrl : Symbol(eventQrl, Decl(stringMappingReduction.ts, 23, 44)) |
| 95 | + |
| 96 | +}; |
| 97 | + |
0 commit comments