|
| 1 | +//// [tests/cases/compiler/contextuallyTypedJsxChildren2.tsx] //// |
| 2 | + |
| 3 | +=== contextuallyTypedJsxChildren2.tsx === |
| 4 | +/// <reference path="react16.d.ts" /> |
| 5 | + |
| 6 | +// https://github.com/microsoft/typescript-go/issues/2802 |
| 7 | + |
| 8 | +import * as React from 'react'; |
| 9 | +>React : Symbol(React, Decl(contextuallyTypedJsxChildren2.tsx, 4, 6)) |
| 10 | + |
| 11 | +declare const TestComponentWithChildren: <T, TParam>(props: { |
| 12 | +>TestComponentWithChildren : Symbol(TestComponentWithChildren, Decl(contextuallyTypedJsxChildren2.tsx, 6, 13)) |
| 13 | +>T : Symbol(T, Decl(contextuallyTypedJsxChildren2.tsx, 6, 42)) |
| 14 | +>TParam : Symbol(TParam, Decl(contextuallyTypedJsxChildren2.tsx, 6, 44)) |
| 15 | +>props : Symbol(props, Decl(contextuallyTypedJsxChildren2.tsx, 6, 53)) |
| 16 | + |
| 17 | + state: T; |
| 18 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 6, 61)) |
| 19 | +>T : Symbol(T, Decl(contextuallyTypedJsxChildren2.tsx, 6, 42)) |
| 20 | + |
| 21 | + selector?: (state: NoInfer<T>) => TParam; |
| 22 | +>selector : Symbol(selector, Decl(contextuallyTypedJsxChildren2.tsx, 7, 11)) |
| 23 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 8, 14)) |
| 24 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 25 | +>T : Symbol(T, Decl(contextuallyTypedJsxChildren2.tsx, 6, 42)) |
| 26 | +>TParam : Symbol(TParam, Decl(contextuallyTypedJsxChildren2.tsx, 6, 44)) |
| 27 | + |
| 28 | + children?: (state: NoInfer<TParam>) => React.ReactElement<any> | null; |
| 29 | +>children : Symbol(children, Decl(contextuallyTypedJsxChildren2.tsx, 8, 43)) |
| 30 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 9, 14)) |
| 31 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 32 | +>TParam : Symbol(TParam, Decl(contextuallyTypedJsxChildren2.tsx, 6, 44)) |
| 33 | +>React : Symbol(React, Decl(contextuallyTypedJsxChildren2.tsx, 4, 6)) |
| 34 | +>ReactElement : Symbol(React.ReactElement, Decl(react16.d.ts, 135, 9)) |
| 35 | + |
| 36 | +}) => React.ReactElement<any>; |
| 37 | +>React : Symbol(React, Decl(contextuallyTypedJsxChildren2.tsx, 4, 6)) |
| 38 | +>ReactElement : Symbol(React.ReactElement, Decl(react16.d.ts, 135, 9)) |
| 39 | + |
| 40 | +declare const TestComponentWithoutChildren: <T, TParam>(props: { |
| 41 | +>TestComponentWithoutChildren : Symbol(TestComponentWithoutChildren, Decl(contextuallyTypedJsxChildren2.tsx, 12, 13)) |
| 42 | +>T : Symbol(T, Decl(contextuallyTypedJsxChildren2.tsx, 12, 45)) |
| 43 | +>TParam : Symbol(TParam, Decl(contextuallyTypedJsxChildren2.tsx, 12, 47)) |
| 44 | +>props : Symbol(props, Decl(contextuallyTypedJsxChildren2.tsx, 12, 56)) |
| 45 | + |
| 46 | + state: T; |
| 47 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 12, 64)) |
| 48 | +>T : Symbol(T, Decl(contextuallyTypedJsxChildren2.tsx, 12, 45)) |
| 49 | + |
| 50 | + selector?: (state: NoInfer<T>) => TParam; |
| 51 | +>selector : Symbol(selector, Decl(contextuallyTypedJsxChildren2.tsx, 13, 11)) |
| 52 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 14, 14)) |
| 53 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 54 | +>T : Symbol(T, Decl(contextuallyTypedJsxChildren2.tsx, 12, 45)) |
| 55 | +>TParam : Symbol(TParam, Decl(contextuallyTypedJsxChildren2.tsx, 12, 47)) |
| 56 | + |
| 57 | + notChildren?: (state: NoInfer<TParam>) => React.ReactElement<any> | null; |
| 58 | +>notChildren : Symbol(notChildren, Decl(contextuallyTypedJsxChildren2.tsx, 14, 43)) |
| 59 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 15, 17)) |
| 60 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 61 | +>TParam : Symbol(TParam, Decl(contextuallyTypedJsxChildren2.tsx, 12, 47)) |
| 62 | +>React : Symbol(React, Decl(contextuallyTypedJsxChildren2.tsx, 4, 6)) |
| 63 | +>ReactElement : Symbol(React.ReactElement, Decl(react16.d.ts, 135, 9)) |
| 64 | + |
| 65 | +}) => React.ReactElement<any>; |
| 66 | +>React : Symbol(React, Decl(contextuallyTypedJsxChildren2.tsx, 4, 6)) |
| 67 | +>ReactElement : Symbol(React.ReactElement, Decl(react16.d.ts, 135, 9)) |
| 68 | + |
| 69 | +const App = () => { |
| 70 | +>App : Symbol(App, Decl(contextuallyTypedJsxChildren2.tsx, 18, 5)) |
| 71 | + |
| 72 | + return ( |
| 73 | + <> |
| 74 | + <TestComponentWithChildren state={{ foo: 123 }} selector={(state) => state.foo}> |
| 75 | +>TestComponentWithChildren : Symbol(TestComponentWithChildren, Decl(contextuallyTypedJsxChildren2.tsx, 6, 13)) |
| 76 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 21, 32)) |
| 77 | +>foo : Symbol(foo, Decl(contextuallyTypedJsxChildren2.tsx, 21, 41)) |
| 78 | +>selector : Symbol(selector, Decl(contextuallyTypedJsxChildren2.tsx, 21, 53)) |
| 79 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 21, 65)) |
| 80 | +>state.foo : Symbol(foo, Decl(contextuallyTypedJsxChildren2.tsx, 21, 41)) |
| 81 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 21, 65)) |
| 82 | +>foo : Symbol(foo, Decl(contextuallyTypedJsxChildren2.tsx, 21, 41)) |
| 83 | + |
| 84 | + {(selected) => <div>{Math.max(selected, 0)}</div>} |
| 85 | +>selected : Symbol(selected, Decl(contextuallyTypedJsxChildren2.tsx, 22, 10)) |
| 86 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2548, 114)) |
| 87 | +>Math.max : Symbol(Math.max, Decl(lib.es5.d.ts, --, --)) |
| 88 | +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) |
| 89 | +>max : Symbol(Math.max, Decl(lib.es5.d.ts, --, --)) |
| 90 | +>selected : Symbol(selected, Decl(contextuallyTypedJsxChildren2.tsx, 22, 10)) |
| 91 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2548, 114)) |
| 92 | + |
| 93 | + </TestComponentWithChildren> |
| 94 | +>TestComponentWithChildren : Symbol(TestComponentWithChildren, Decl(contextuallyTypedJsxChildren2.tsx, 6, 13)) |
| 95 | + |
| 96 | + <TestComponentWithoutChildren |
| 97 | +>TestComponentWithoutChildren : Symbol(TestComponentWithoutChildren, Decl(contextuallyTypedJsxChildren2.tsx, 12, 13)) |
| 98 | + |
| 99 | + state={{ foo: 123 }} |
| 100 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 25, 35)) |
| 101 | +>foo : Symbol(foo, Decl(contextuallyTypedJsxChildren2.tsx, 26, 16)) |
| 102 | + |
| 103 | + selector={(state) => state.foo} |
| 104 | +>selector : Symbol(selector, Decl(contextuallyTypedJsxChildren2.tsx, 26, 28)) |
| 105 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 27, 19)) |
| 106 | +>state.foo : Symbol(foo, Decl(contextuallyTypedJsxChildren2.tsx, 26, 16)) |
| 107 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 27, 19)) |
| 108 | +>foo : Symbol(foo, Decl(contextuallyTypedJsxChildren2.tsx, 26, 16)) |
| 109 | + |
| 110 | + notChildren={(selected) => <div>{Math.max(selected, 0)}</div>} |
| 111 | +>notChildren : Symbol(notChildren, Decl(contextuallyTypedJsxChildren2.tsx, 27, 39)) |
| 112 | +>selected : Symbol(selected, Decl(contextuallyTypedJsxChildren2.tsx, 28, 22)) |
| 113 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2548, 114)) |
| 114 | +>Math.max : Symbol(Math.max, Decl(lib.es5.d.ts, --, --)) |
| 115 | +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) |
| 116 | +>max : Symbol(Math.max, Decl(lib.es5.d.ts, --, --)) |
| 117 | +>selected : Symbol(selected, Decl(contextuallyTypedJsxChildren2.tsx, 28, 22)) |
| 118 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2548, 114)) |
| 119 | + |
| 120 | + /> |
| 121 | + </> |
| 122 | + ); |
| 123 | +}; |
| 124 | + |
| 125 | +// https://github.com/microsoft/typescript-go/issues/2797 |
| 126 | + |
| 127 | +interface State { |
| 128 | +>State : Symbol(State, Decl(contextuallyTypedJsxChildren2.tsx, 32, 2)) |
| 129 | + |
| 130 | + value: boolean |
| 131 | +>value : Symbol(State.value, Decl(contextuallyTypedJsxChildren2.tsx, 36, 17)) |
| 132 | +} |
| 133 | + |
| 134 | +declare const Subscribe: <TSelected = State>(props: { |
| 135 | +>Subscribe : Symbol(Subscribe, Decl(contextuallyTypedJsxChildren2.tsx, 40, 13)) |
| 136 | +>TSelected : Symbol(TSelected, Decl(contextuallyTypedJsxChildren2.tsx, 40, 26)) |
| 137 | +>State : Symbol(State, Decl(contextuallyTypedJsxChildren2.tsx, 32, 2)) |
| 138 | +>props : Symbol(props, Decl(contextuallyTypedJsxChildren2.tsx, 40, 45)) |
| 139 | + |
| 140 | + selector?: (state: State) => TSelected |
| 141 | +>selector : Symbol(selector, Decl(contextuallyTypedJsxChildren2.tsx, 40, 53)) |
| 142 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 41, 14)) |
| 143 | +>State : Symbol(State, Decl(contextuallyTypedJsxChildren2.tsx, 32, 2)) |
| 144 | +>TSelected : Symbol(TSelected, Decl(contextuallyTypedJsxChildren2.tsx, 40, 26)) |
| 145 | + |
| 146 | + children: (state: TSelected) => void |
| 147 | +>children : Symbol(children, Decl(contextuallyTypedJsxChildren2.tsx, 41, 40)) |
| 148 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 42, 13)) |
| 149 | +>TSelected : Symbol(TSelected, Decl(contextuallyTypedJsxChildren2.tsx, 40, 26)) |
| 150 | + |
| 151 | +}) => React.ReactElement<any> |
| 152 | +>React : Symbol(React, Decl(contextuallyTypedJsxChildren2.tsx, 4, 6)) |
| 153 | +>ReactElement : Symbol(React.ReactElement, Decl(react16.d.ts, 135, 9)) |
| 154 | + |
| 155 | +const _result = ( |
| 156 | +>_result : Symbol(_result, Decl(contextuallyTypedJsxChildren2.tsx, 45, 5)) |
| 157 | + |
| 158 | + <Subscribe |
| 159 | +>Subscribe : Symbol(Subscribe, Decl(contextuallyTypedJsxChildren2.tsx, 40, 13)) |
| 160 | + |
| 161 | + selector={(state) => { |
| 162 | +>selector : Symbol(selector, Decl(contextuallyTypedJsxChildren2.tsx, 46, 12)) |
| 163 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 47, 15)) |
| 164 | + |
| 165 | + return [state.value] |
| 166 | +>state.value : Symbol(State.value, Decl(contextuallyTypedJsxChildren2.tsx, 36, 17)) |
| 167 | +>state : Symbol(state, Decl(contextuallyTypedJsxChildren2.tsx, 47, 15)) |
| 168 | +>value : Symbol(State.value, Decl(contextuallyTypedJsxChildren2.tsx, 36, 17)) |
| 169 | + |
| 170 | + }} |
| 171 | + > |
| 172 | + {([value = false]) => { |
| 173 | +>value : Symbol(value, Decl(contextuallyTypedJsxChildren2.tsx, 51, 7)) |
| 174 | + |
| 175 | + console.log(value) |
| 176 | +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 177 | +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) |
| 178 | +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) |
| 179 | +>value : Symbol(value, Decl(contextuallyTypedJsxChildren2.tsx, 51, 7)) |
| 180 | + |
| 181 | + }} |
| 182 | + </Subscribe> |
| 183 | +>Subscribe : Symbol(Subscribe, Decl(contextuallyTypedJsxChildren2.tsx, 40, 13)) |
| 184 | + |
| 185 | +) |
| 186 | + |
0 commit comments