|
| 1 | +=== tests/cases/conformance/jsx/file.tsx === |
| 2 | +import * as React from "react"; |
| 3 | +>React : Symbol(React, Decl(file.tsx, 0, 6)) |
| 4 | + |
| 5 | +interface BaseProps<T> { |
| 6 | +>BaseProps : Symbol(BaseProps, Decl(file.tsx, 0, 31)) |
| 7 | +>T : Symbol(T, Decl(file.tsx, 1, 20)) |
| 8 | + |
| 9 | + initialValues: T; |
| 10 | +>initialValues : Symbol(BaseProps.initialValues, Decl(file.tsx, 1, 24)) |
| 11 | +>T : Symbol(T, Decl(file.tsx, 1, 20)) |
| 12 | + |
| 13 | + nextValues: (cur: T) => T; |
| 14 | +>nextValues : Symbol(BaseProps.nextValues, Decl(file.tsx, 2, 19)) |
| 15 | +>cur : Symbol(cur, Decl(file.tsx, 3, 15)) |
| 16 | +>T : Symbol(T, Decl(file.tsx, 1, 20)) |
| 17 | +>T : Symbol(T, Decl(file.tsx, 1, 20)) |
| 18 | +} |
| 19 | +declare class GenericComponent<Props = {}, Values = object> extends React.Component<Props & BaseProps<Values>, {}> { |
| 20 | +>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1)) |
| 21 | +>Props : Symbol(Props, Decl(file.tsx, 5, 31)) |
| 22 | +>Values : Symbol(Values, Decl(file.tsx, 5, 42)) |
| 23 | +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) |
| 24 | +>React : Symbol(React, Decl(file.tsx, 0, 6)) |
| 25 | +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) |
| 26 | +>Props : Symbol(Props, Decl(file.tsx, 5, 31)) |
| 27 | +>BaseProps : Symbol(BaseProps, Decl(file.tsx, 0, 31)) |
| 28 | +>Values : Symbol(Values, Decl(file.tsx, 5, 42)) |
| 29 | + |
| 30 | + iv: Values; |
| 31 | +>iv : Symbol(GenericComponent.iv, Decl(file.tsx, 5, 116)) |
| 32 | +>Values : Symbol(Values, Decl(file.tsx, 5, 42)) |
| 33 | +} |
| 34 | + |
| 35 | +let a = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a} />; // No error |
| 36 | +>a : Symbol(a, Decl(file.tsx, 9, 3)) |
| 37 | +>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1)) |
| 38 | +>initialValues : Symbol(initialValues, Decl(file.tsx, 9, 25)) |
| 39 | +>x : Symbol(x, Decl(file.tsx, 9, 42)) |
| 40 | +>nextValues : Symbol(nextValues, Decl(file.tsx, 9, 52)) |
| 41 | +>a : Symbol(a, Decl(file.tsx, 9, 65)) |
| 42 | +>a : Symbol(a, Decl(file.tsx, 9, 65)) |
| 43 | + |
| 44 | +let b = <GenericComponent initialValues={12} nextValues={a => a} />; // No error - Values should be reinstantiated with `number` (since `object` is a default, not a constraint) |
| 45 | +>b : Symbol(b, Decl(file.tsx, 10, 3)) |
| 46 | +>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1)) |
| 47 | +>initialValues : Symbol(initialValues, Decl(file.tsx, 10, 25)) |
| 48 | +>nextValues : Symbol(nextValues, Decl(file.tsx, 10, 44)) |
| 49 | +>a : Symbol(a, Decl(file.tsx, 10, 57)) |
| 50 | +>a : Symbol(a, Decl(file.tsx, 10, 57)) |
| 51 | + |
| 52 | +let c = <GenericComponent initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error |
| 53 | +>c : Symbol(c, Decl(file.tsx, 11, 3)) |
| 54 | +>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1)) |
| 55 | +>initialValues : Symbol(initialValues, Decl(file.tsx, 11, 25)) |
| 56 | +>x : Symbol(x, Decl(file.tsx, 11, 42)) |
| 57 | +>nextValues : Symbol(nextValues, Decl(file.tsx, 11, 52)) |
| 58 | +>a : Symbol(a, Decl(file.tsx, 11, 65)) |
| 59 | +>x : Symbol(x, Decl(file.tsx, 11, 72)) |
| 60 | +>a.x : Symbol(x, Decl(file.tsx, 11, 42)) |
| 61 | +>a : Symbol(a, Decl(file.tsx, 11, 65)) |
| 62 | +>x : Symbol(x, Decl(file.tsx, 11, 42)) |
| 63 | + |
| 64 | +let d = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a.x} />; // Error - `string` is not assignable to `{x: string}` |
| 65 | +>d : Symbol(d, Decl(file.tsx, 12, 3)) |
| 66 | +>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1)) |
| 67 | +>initialValues : Symbol(initialValues, Decl(file.tsx, 12, 25)) |
| 68 | +>x : Symbol(x, Decl(file.tsx, 12, 42)) |
| 69 | +>nextValues : Symbol(nextValues, Decl(file.tsx, 12, 52)) |
| 70 | +>a : Symbol(a, Decl(file.tsx, 12, 65)) |
| 71 | +>a.x : Symbol(x, Decl(file.tsx, 12, 42)) |
| 72 | +>a : Symbol(a, Decl(file.tsx, 12, 65)) |
| 73 | +>x : Symbol(x, Decl(file.tsx, 12, 42)) |
| 74 | + |
0 commit comments