File: jsxInferenceProducesLiteralAsExpected.types

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (55 lines) | stat: -rw-r--r-- 1,354 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
=== tests/cases/compiler/jsxInferenceProducesLiteralAsExpected.tsx ===
import React = require("react");
>React : typeof React

type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
>FunctionPropertyNames : FunctionPropertyNames<T>

class TestObject {
>TestObject : TestObject

    a: string = '';
>a : string
>'' : ""

    b: number = 1;
>b : number
>1 : 1

    c: () => void = () => { };
>c : () => void
>() => { } : () => void
}
interface TestProps<T> {
    model: T;
>model : T

    foo: FunctionPropertyNames<T>;
>foo : FunctionPropertyNames<T>
}
function Test<T>(props: TestProps<T>) { return <></>; }
>Test : <T>(props: TestProps<T>) => JSX.Element
>props : TestProps<T>
><></> : JSX.Element

const model = new TestObject();
>model : TestObject
>new TestObject() : TestObject
>TestObject : typeof TestObject

const el1 = <Test model={model} foo="c" />;
>el1 : JSX.Element
><Test model={model} foo="c" /> : JSX.Element
>Test : <T>(props: TestProps<T>) => JSX.Element
>model : TestObject
>model : TestObject
>foo : "c"

const el2 = <Test<TestObject> model={model} foo="c" />;
>el2 : JSX.Element
><Test<TestObject> model={model} foo="c" /> : JSX.Element
>Test : <T>(props: TestProps<T>) => JSX.Element
>model : TestObject
>model : TestObject
>foo : "c"