File: tsxTypeArgumentResolution.js

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (80 lines) | stat: -rw-r--r-- 2,339 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//// [file.tsx]
import React = require('react');

interface Prop {
    a: number,
    b: string
}

declare class MyComp<P> extends React.Component<P, {}> {
    internalProp: P;
}

let x = <MyComp<Prop> a={10} b="hi" />; // OK

x = <MyComp<Prop> a={10} b="hi"></MyComp>; // OK

x = <MyComp<Prop> a={10} b={20} />; // error

x = <MyComp<Prop> a={10} b={20}></MyComp>; // error

x = <MyComp<Prop, Prop> a={10} b="hi" />; // error

x = <MyComp<Prop, Prop> a={10} b="hi"></MyComp>; // error

x = <MyComp<> a={10} b="hi" />; // error

x = <MyComp<> a={10} b="hi"></MyComp>; // error

x= <MyComp<{}> /> // OK

x= <MyComp<{}>></MyComp> // OK

declare class MyComp2<P extends { a: string }, P2 = {}> extends React.Component<P & P2, {}> {
    internalProp: [P, P2];
}
x = <MyComp2<{a: string, b: string}> a="a" b="b" />; // OK

x = <MyComp2<{a: string, b: string}> a="a" b="b"></MyComp2>; // OK

x = <MyComp2<Prop> a={10} b="hi" />; // error

x = <MyComp2<Prop> a={10} b="hi"></MyComp2>; // error

x = <MyComp2<{a: string}, {b: string}> a="hi" b="hi" />; // OK

x = <MyComp2<{a: string}, {b: string}> a="hi" b="hi"></MyComp2>; // OK

x = <MyComp2<{a: string}, {b: string}, Prop> a="hi" b="hi" />; // error

x = <MyComp2<{a: string}, {b: string}, Prop> a="hi" b="hi"></MyComp2>; // error

x = <MyComp2<{a: string}, {b: number}> a="hi" b="hi" />; // error

x = <MyComp2<{a: string}, {b: number}> a="hi" b="hi"></MyComp2>; // error


//// [file.jsx]
"use strict";
exports.__esModule = true;
var React = require("react");
var x = <MyComp a={10} b="hi"/>; // OK
x = <MyComp a={10} b="hi"></MyComp>; // OK
x = <MyComp a={10} b={20}/>; // error
x = <MyComp a={10} b={20}></MyComp>; // error
x = <MyComp a={10} b="hi"/>; // error
x = <MyComp a={10} b="hi"></MyComp>; // error
x = <MyComp a={10} b="hi"/>; // error
x = <MyComp a={10} b="hi"></MyComp>; // error
x = <MyComp />; // OK
x = <MyComp></MyComp>; // OK
x = <MyComp2 a="a" b="b"/>; // OK
x = <MyComp2 a="a" b="b"></MyComp2>; // OK
x = <MyComp2 a={10} b="hi"/>; // error
x = <MyComp2 a={10} b="hi"></MyComp2>; // error
x = <MyComp2 a="hi" b="hi"/>; // OK
x = <MyComp2 a="hi" b="hi"></MyComp2>; // OK
x = <MyComp2 a="hi" b="hi"/>; // error
x = <MyComp2 a="hi" b="hi"></MyComp2>; // error
x = <MyComp2 a="hi" b="hi"/>; // error
x = <MyComp2 a="hi" b="hi"></MyComp2>; // error