|
| 1 | +//// [tests/cases/compiler/genericCallInferenceConditionalType2.ts] //// |
| 2 | + |
| 3 | +=== genericCallInferenceConditionalType2.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/59490 |
| 5 | + |
| 6 | +type ComponentProps<T> = T extends (props: infer P) => unknown ? P : never; |
| 7 | +>ComponentProps : Symbol(ComponentProps, Decl(genericCallInferenceConditionalType2.ts, 0, 0)) |
| 8 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 2, 20)) |
| 9 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 2, 20)) |
| 10 | +>props : Symbol(props, Decl(genericCallInferenceConditionalType2.ts, 2, 36)) |
| 11 | +>P : Symbol(P, Decl(genericCallInferenceConditionalType2.ts, 2, 48)) |
| 12 | +>P : Symbol(P, Decl(genericCallInferenceConditionalType2.ts, 2, 48)) |
| 13 | + |
| 14 | +declare function wrapComponent<P>( |
| 15 | +>wrapComponent : Symbol(wrapComponent, Decl(genericCallInferenceConditionalType2.ts, 2, 75)) |
| 16 | +>P : Symbol(P, Decl(genericCallInferenceConditionalType2.ts, 4, 31)) |
| 17 | + |
| 18 | + component: (props: P) => unknown, |
| 19 | +>component : Symbol(component, Decl(genericCallInferenceConditionalType2.ts, 4, 34)) |
| 20 | +>props : Symbol(props, Decl(genericCallInferenceConditionalType2.ts, 5, 14)) |
| 21 | +>P : Symbol(P, Decl(genericCallInferenceConditionalType2.ts, 4, 31)) |
| 22 | + |
| 23 | +): (props: P) => unknown; |
| 24 | +>props : Symbol(props, Decl(genericCallInferenceConditionalType2.ts, 6, 4)) |
| 25 | +>P : Symbol(P, Decl(genericCallInferenceConditionalType2.ts, 4, 31)) |
| 26 | + |
| 27 | +const WrappedComponent = wrapComponent( |
| 28 | +>WrappedComponent : Symbol(WrappedComponent, Decl(genericCallInferenceConditionalType2.ts, 8, 5)) |
| 29 | +>wrapComponent : Symbol(wrapComponent, Decl(genericCallInferenceConditionalType2.ts, 2, 75)) |
| 30 | + |
| 31 | + <T extends string = "span">(props: { |
| 32 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 9, 3)) |
| 33 | +>props : Symbol(props, Decl(genericCallInferenceConditionalType2.ts, 9, 30)) |
| 34 | + |
| 35 | + as?: T | undefined; |
| 36 | +>as : Symbol(as, Decl(genericCallInferenceConditionalType2.ts, 9, 38)) |
| 37 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 9, 3)) |
| 38 | + |
| 39 | + className?: string; |
| 40 | +>className : Symbol(className, Decl(genericCallInferenceConditionalType2.ts, 10, 23)) |
| 41 | + |
| 42 | + }) => { |
| 43 | + return null; |
| 44 | + }, |
| 45 | +); |
| 46 | + |
| 47 | +type RetrievedProps = ComponentProps<typeof WrappedComponent>; |
| 48 | +>RetrievedProps : Symbol(RetrievedProps, Decl(genericCallInferenceConditionalType2.ts, 15, 2)) |
| 49 | +>ComponentProps : Symbol(ComponentProps, Decl(genericCallInferenceConditionalType2.ts, 0, 0)) |
| 50 | +>WrappedComponent : Symbol(WrappedComponent, Decl(genericCallInferenceConditionalType2.ts, 8, 5)) |
| 51 | + |
| 52 | +declare const f: <T>(f: (x: T) => unknown) => (x: T) => unknown |
| 53 | +>f : Symbol(f, Decl(genericCallInferenceConditionalType2.ts, 19, 13)) |
| 54 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 19, 18)) |
| 55 | +>f : Symbol(f, Decl(genericCallInferenceConditionalType2.ts, 19, 21)) |
| 56 | +>x : Symbol(x, Decl(genericCallInferenceConditionalType2.ts, 19, 25)) |
| 57 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 19, 18)) |
| 58 | +>x : Symbol(x, Decl(genericCallInferenceConditionalType2.ts, 19, 47)) |
| 59 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 19, 18)) |
| 60 | + |
| 61 | +declare const g: <T extends unknown = string>(x: { foo: T }) => unknown |
| 62 | +>g : Symbol(g, Decl(genericCallInferenceConditionalType2.ts, 20, 13)) |
| 63 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 20, 18)) |
| 64 | +>x : Symbol(x, Decl(genericCallInferenceConditionalType2.ts, 20, 46)) |
| 65 | +>foo : Symbol(foo, Decl(genericCallInferenceConditionalType2.ts, 20, 50)) |
| 66 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 20, 18)) |
| 67 | + |
| 68 | +const h = f(g) |
| 69 | +>h : Symbol(h, Decl(genericCallInferenceConditionalType2.ts, 22, 5)) |
| 70 | +>f : Symbol(f, Decl(genericCallInferenceConditionalType2.ts, 19, 13)) |
| 71 | +>g : Symbol(g, Decl(genericCallInferenceConditionalType2.ts, 20, 13)) |
| 72 | + |
| 73 | +type FirstParameter<T> = T extends (x: infer P) => unknown ? P : unknown |
| 74 | +>FirstParameter : Symbol(FirstParameter, Decl(genericCallInferenceConditionalType2.ts, 22, 14)) |
| 75 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 24, 20)) |
| 76 | +>T : Symbol(T, Decl(genericCallInferenceConditionalType2.ts, 24, 20)) |
| 77 | +>x : Symbol(x, Decl(genericCallInferenceConditionalType2.ts, 24, 36)) |
| 78 | +>P : Symbol(P, Decl(genericCallInferenceConditionalType2.ts, 24, 44)) |
| 79 | +>P : Symbol(P, Decl(genericCallInferenceConditionalType2.ts, 24, 44)) |
| 80 | + |
| 81 | +type X = FirstParameter<typeof h>['foo'] |
| 82 | +>X : Symbol(X, Decl(genericCallInferenceConditionalType2.ts, 24, 72)) |
| 83 | +>FirstParameter : Symbol(FirstParameter, Decl(genericCallInferenceConditionalType2.ts, 22, 14)) |
| 84 | +>h : Symbol(h, Decl(genericCallInferenceConditionalType2.ts, 22, 5)) |
| 85 | + |
0 commit comments