Skip to content

Commit 378f444

Browse files
author
Kanchalai Tanglertsampan
committed
Add tests and update baselines
1 parent 0b4f25c commit 378f444

11 files changed

+274
-308
lines changed

tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments1.errors.txt

Lines changed: 0 additions & 59 deletions
This file was deleted.

tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments1.js

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import React = require('react')
44

5-
65
declare function ComponentWithTwoAttributes<K,V>(l: {key1: K, value: V}): JSX.Element;
76

87
// OK
@@ -11,23 +10,6 @@ function Baz<T,U>(key1: T, value: U) {
1110
let a1 = <ComponentWithTwoAttributes {...{key1, value: value}} key="Component" />
1211
}
1312

14-
// OK
15-
declare function Component<U>(l: U): JSX.Element;
16-
function createComponent<T extends {prop: number}>(arg:T) {
17-
let a1 = <Component {...arg} />;
18-
let a2 = <Component {...arg} prop1 />;
19-
}
20-
21-
declare function ComponentSpecific<U>(l: {prop: U}): JSX.Element;
22-
declare function ComponentSpecific1<U>(l: {prop: U, "ignore-prop": number}): JSX.Element;
23-
24-
// OK
25-
function Bar<T extends {prop: number}>(arg: T) {
26-
let a1 = <ComponentSpecific {...arg} ignore-prop="hi" />; // U is number
27-
let a2 = <ComponentSpecific1 {...arg} ignore-prop={10} />; // U is number
28-
let a3 = <ComponentSpecific {...arg} prop="hello" />; // U is "hello"
29-
}
30-
3113
declare function Link<U>(l: {func: (arg: U)=>void}): JSX.Element;
3214

3315
// OK
@@ -39,7 +21,15 @@ function createLink1(func: (a: number)=>boolean) {
3921
let o = <Link func={func} />
4022
}
4123

42-
24+
interface InferParamProp<T> {
25+
values: Array<T>;
26+
selectHandler: (selectedVal: T) => void;
27+
}
28+
29+
declare function InferParamComponent<T>(attr: InferParamProp<T>): JSX.Element;
30+
31+
// OK
32+
let i = <InferParamComponent values={[1, 2, 3, 4]} selectHandler={(val) => { }} />;
4333

4434
//// [file.jsx]
4535
define(["require", "exports", "react"], function (require, exports, React) {
@@ -49,21 +39,13 @@ define(["require", "exports", "react"], function (require, exports, React) {
4939
var a0 = <ComponentWithTwoAttributes key1={key1} value={value}/>;
5040
var a1 = <ComponentWithTwoAttributes {...{ key1: key1, value: value }} key="Component"/>;
5141
}
52-
function createComponent(arg) {
53-
var a1 = <Component {...arg}/>;
54-
var a2 = <Component {...arg} prop1/>;
55-
}
56-
// OK
57-
function Bar(arg) {
58-
var a1 = <ComponentSpecific {...arg} ignore-prop="hi"/>; // U is number
59-
var a2 = <ComponentSpecific1 {...arg} ignore-prop={10}/>; // U is number
60-
var a3 = <ComponentSpecific {...arg} prop="hello"/>; // U is "hello"
61-
}
6242
// OK
6343
function createLink(func) {
6444
var o = <Link func={func}/>;
6545
}
6646
function createLink1(func) {
6747
var o = <Link func={func}/>;
6848
}
49+
// OK
50+
var i = <InferParamComponent values={[1, 2, 3, 4]} selectHandler={function (val) { }}/>;
6951
});

tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments1.symbols

Lines changed: 75 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -3,152 +3,109 @@
33
import React = require('react')
44
>React : Symbol(React, Decl(file.tsx, 0, 0))
55

6-
76
declare function ComponentWithTwoAttributes<K,V>(l: {key1: K, value: V}): JSX.Element;
87
>ComponentWithTwoAttributes : Symbol(ComponentWithTwoAttributes, Decl(file.tsx, 1, 31))
9-
>K : Symbol(K, Decl(file.tsx, 4, 44))
10-
>V : Symbol(V, Decl(file.tsx, 4, 46))
11-
>l : Symbol(l, Decl(file.tsx, 4, 49))
12-
>key1 : Symbol(key1, Decl(file.tsx, 4, 53))
13-
>K : Symbol(K, Decl(file.tsx, 4, 44))
14-
>value : Symbol(value, Decl(file.tsx, 4, 61))
15-
>V : Symbol(V, Decl(file.tsx, 4, 46))
8+
>K : Symbol(K, Decl(file.tsx, 3, 44))
9+
>V : Symbol(V, Decl(file.tsx, 3, 46))
10+
>l : Symbol(l, Decl(file.tsx, 3, 49))
11+
>key1 : Symbol(key1, Decl(file.tsx, 3, 53))
12+
>K : Symbol(K, Decl(file.tsx, 3, 44))
13+
>value : Symbol(value, Decl(file.tsx, 3, 61))
14+
>V : Symbol(V, Decl(file.tsx, 3, 46))
1615
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
1716
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
1817

1918
// OK
2019
function Baz<T,U>(key1: T, value: U) {
21-
>Baz : Symbol(Baz, Decl(file.tsx, 4, 86))
22-
>T : Symbol(T, Decl(file.tsx, 7, 13))
23-
>U : Symbol(U, Decl(file.tsx, 7, 15))
24-
>key1 : Symbol(key1, Decl(file.tsx, 7, 18))
25-
>T : Symbol(T, Decl(file.tsx, 7, 13))
26-
>value : Symbol(value, Decl(file.tsx, 7, 26))
27-
>U : Symbol(U, Decl(file.tsx, 7, 15))
20+
>Baz : Symbol(Baz, Decl(file.tsx, 3, 86))
21+
>T : Symbol(T, Decl(file.tsx, 6, 13))
22+
>U : Symbol(U, Decl(file.tsx, 6, 15))
23+
>key1 : Symbol(key1, Decl(file.tsx, 6, 18))
24+
>T : Symbol(T, Decl(file.tsx, 6, 13))
25+
>value : Symbol(value, Decl(file.tsx, 6, 26))
26+
>U : Symbol(U, Decl(file.tsx, 6, 15))
2827

2928
let a0 = <ComponentWithTwoAttributes key1={key1} value={value} />
30-
>a0 : Symbol(a0, Decl(file.tsx, 8, 7))
29+
>a0 : Symbol(a0, Decl(file.tsx, 7, 7))
3130
>ComponentWithTwoAttributes : Symbol(ComponentWithTwoAttributes, Decl(file.tsx, 1, 31))
32-
>key1 : Symbol(key1, Decl(file.tsx, 8, 40))
33-
>key1 : Symbol(key1, Decl(file.tsx, 7, 18))
34-
>value : Symbol(value, Decl(file.tsx, 8, 52))
35-
>value : Symbol(value, Decl(file.tsx, 7, 26))
31+
>key1 : Symbol(key1, Decl(file.tsx, 7, 40))
32+
>key1 : Symbol(key1, Decl(file.tsx, 6, 18))
33+
>value : Symbol(value, Decl(file.tsx, 7, 52))
34+
>value : Symbol(value, Decl(file.tsx, 6, 26))
3635

3736
let a1 = <ComponentWithTwoAttributes {...{key1, value: value}} key="Component" />
38-
>a1 : Symbol(a1, Decl(file.tsx, 9, 7))
37+
>a1 : Symbol(a1, Decl(file.tsx, 8, 7))
3938
>ComponentWithTwoAttributes : Symbol(ComponentWithTwoAttributes, Decl(file.tsx, 1, 31))
40-
>key1 : Symbol(key1, Decl(file.tsx, 9, 46))
41-
>value : Symbol(value, Decl(file.tsx, 9, 51))
42-
>value : Symbol(value, Decl(file.tsx, 7, 26))
43-
>key : Symbol(key, Decl(file.tsx, 9, 66))
44-
}
45-
46-
// OK
47-
declare function Component<U>(l: U): JSX.Element;
48-
>Component : Symbol(Component, Decl(file.tsx, 10, 1))
49-
>U : Symbol(U, Decl(file.tsx, 13, 27))
50-
>l : Symbol(l, Decl(file.tsx, 13, 30))
51-
>U : Symbol(U, Decl(file.tsx, 13, 27))
52-
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
53-
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
54-
55-
function createComponent<T extends {prop: number}>(arg:T) {
56-
>createComponent : Symbol(createComponent, Decl(file.tsx, 13, 49))
57-
>T : Symbol(T, Decl(file.tsx, 14, 25))
58-
>prop : Symbol(prop, Decl(file.tsx, 14, 36))
59-
>arg : Symbol(arg, Decl(file.tsx, 14, 51))
60-
>T : Symbol(T, Decl(file.tsx, 14, 25))
61-
62-
let a1 = <Component {...arg} />;
63-
>a1 : Symbol(a1, Decl(file.tsx, 15, 7))
64-
>Component : Symbol(Component, Decl(file.tsx, 10, 1))
65-
>arg : Symbol(arg, Decl(file.tsx, 14, 51))
66-
67-
let a2 = <Component {...arg} prop1 />;
68-
>a2 : Symbol(a2, Decl(file.tsx, 16, 7))
69-
>Component : Symbol(Component, Decl(file.tsx, 10, 1))
70-
>arg : Symbol(arg, Decl(file.tsx, 14, 51))
71-
>prop1 : Symbol(prop1, Decl(file.tsx, 16, 32))
72-
}
73-
74-
declare function ComponentSpecific<U>(l: {prop: U}): JSX.Element;
75-
>ComponentSpecific : Symbol(ComponentSpecific, Decl(file.tsx, 17, 1))
76-
>U : Symbol(U, Decl(file.tsx, 19, 35))
77-
>l : Symbol(l, Decl(file.tsx, 19, 38))
78-
>prop : Symbol(prop, Decl(file.tsx, 19, 42))
79-
>U : Symbol(U, Decl(file.tsx, 19, 35))
80-
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
81-
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
82-
83-
declare function ComponentSpecific1<U>(l: {prop: U, "ignore-prop": number}): JSX.Element;
84-
>ComponentSpecific1 : Symbol(ComponentSpecific1, Decl(file.tsx, 19, 65))
85-
>U : Symbol(U, Decl(file.tsx, 20, 36))
86-
>l : Symbol(l, Decl(file.tsx, 20, 39))
87-
>prop : Symbol(prop, Decl(file.tsx, 20, 43))
88-
>U : Symbol(U, Decl(file.tsx, 20, 36))
89-
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
90-
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
91-
92-
// OK
93-
function Bar<T extends {prop: number}>(arg: T) {
94-
>Bar : Symbol(Bar, Decl(file.tsx, 20, 89))
95-
>T : Symbol(T, Decl(file.tsx, 23, 13))
96-
>prop : Symbol(prop, Decl(file.tsx, 23, 24))
97-
>arg : Symbol(arg, Decl(file.tsx, 23, 39))
98-
>T : Symbol(T, Decl(file.tsx, 23, 13))
99-
100-
let a1 = <ComponentSpecific {...arg} ignore-prop="hi" />; // U is number
101-
>a1 : Symbol(a1, Decl(file.tsx, 24, 7))
102-
>ComponentSpecific : Symbol(ComponentSpecific, Decl(file.tsx, 17, 1))
103-
>arg : Symbol(arg, Decl(file.tsx, 23, 39))
104-
>ignore-prop : Symbol(ignore-prop, Decl(file.tsx, 24, 40))
105-
106-
let a2 = <ComponentSpecific1 {...arg} ignore-prop={10} />; // U is number
107-
>a2 : Symbol(a2, Decl(file.tsx, 25, 7))
108-
>ComponentSpecific1 : Symbol(ComponentSpecific1, Decl(file.tsx, 19, 65))
109-
>arg : Symbol(arg, Decl(file.tsx, 23, 39))
110-
>ignore-prop : Symbol(ignore-prop, Decl(file.tsx, 25, 41))
111-
112-
let a3 = <ComponentSpecific {...arg} prop="hello" />; // U is "hello"
113-
>a3 : Symbol(a3, Decl(file.tsx, 26, 7))
114-
>ComponentSpecific : Symbol(ComponentSpecific, Decl(file.tsx, 17, 1))
115-
>arg : Symbol(arg, Decl(file.tsx, 23, 39))
116-
>prop : Symbol(prop, Decl(file.tsx, 26, 40))
39+
>key1 : Symbol(key1, Decl(file.tsx, 8, 46))
40+
>value : Symbol(value, Decl(file.tsx, 8, 51))
41+
>value : Symbol(value, Decl(file.tsx, 6, 26))
42+
>key : Symbol(key, Decl(file.tsx, 8, 66))
11743
}
11844

11945
declare function Link<U>(l: {func: (arg: U)=>void}): JSX.Element;
120-
>Link : Symbol(Link, Decl(file.tsx, 27, 1))
121-
>U : Symbol(U, Decl(file.tsx, 29, 22))
122-
>l : Symbol(l, Decl(file.tsx, 29, 25))
123-
>func : Symbol(func, Decl(file.tsx, 29, 29))
124-
>arg : Symbol(arg, Decl(file.tsx, 29, 36))
125-
>U : Symbol(U, Decl(file.tsx, 29, 22))
46+
>Link : Symbol(Link, Decl(file.tsx, 9, 1))
47+
>U : Symbol(U, Decl(file.tsx, 11, 22))
48+
>l : Symbol(l, Decl(file.tsx, 11, 25))
49+
>func : Symbol(func, Decl(file.tsx, 11, 29))
50+
>arg : Symbol(arg, Decl(file.tsx, 11, 36))
51+
>U : Symbol(U, Decl(file.tsx, 11, 22))
12652
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
12753
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
12854

12955
// OK
13056
function createLink(func: (a: number)=>void) {
131-
>createLink : Symbol(createLink, Decl(file.tsx, 29, 65))
132-
>func : Symbol(func, Decl(file.tsx, 32, 20))
133-
>a : Symbol(a, Decl(file.tsx, 32, 27))
57+
>createLink : Symbol(createLink, Decl(file.tsx, 11, 65))
58+
>func : Symbol(func, Decl(file.tsx, 14, 20))
59+
>a : Symbol(a, Decl(file.tsx, 14, 27))
13460

13561
let o = <Link func={func} />
136-
>o : Symbol(o, Decl(file.tsx, 33, 7))
137-
>Link : Symbol(Link, Decl(file.tsx, 27, 1))
138-
>func : Symbol(func, Decl(file.tsx, 33, 17))
139-
>func : Symbol(func, Decl(file.tsx, 32, 20))
62+
>o : Symbol(o, Decl(file.tsx, 15, 7))
63+
>Link : Symbol(Link, Decl(file.tsx, 9, 1))
64+
>func : Symbol(func, Decl(file.tsx, 15, 17))
65+
>func : Symbol(func, Decl(file.tsx, 14, 20))
14066
}
14167

14268
function createLink1(func: (a: number)=>boolean) {
143-
>createLink1 : Symbol(createLink1, Decl(file.tsx, 34, 1))
144-
>func : Symbol(func, Decl(file.tsx, 36, 21))
145-
>a : Symbol(a, Decl(file.tsx, 36, 28))
69+
>createLink1 : Symbol(createLink1, Decl(file.tsx, 16, 1))
70+
>func : Symbol(func, Decl(file.tsx, 18, 21))
71+
>a : Symbol(a, Decl(file.tsx, 18, 28))
14672

14773
let o = <Link func={func} />
148-
>o : Symbol(o, Decl(file.tsx, 37, 7))
149-
>Link : Symbol(Link, Decl(file.tsx, 27, 1))
150-
>func : Symbol(func, Decl(file.tsx, 37, 17))
151-
>func : Symbol(func, Decl(file.tsx, 36, 21))
74+
>o : Symbol(o, Decl(file.tsx, 19, 7))
75+
>Link : Symbol(Link, Decl(file.tsx, 9, 1))
76+
>func : Symbol(func, Decl(file.tsx, 19, 17))
77+
>func : Symbol(func, Decl(file.tsx, 18, 21))
78+
}
79+
80+
interface InferParamProp<T> {
81+
>InferParamProp : Symbol(InferParamProp, Decl(file.tsx, 20, 1))
82+
>T : Symbol(T, Decl(file.tsx, 22, 25))
83+
84+
values: Array<T>;
85+
>values : Symbol(InferParamProp.values, Decl(file.tsx, 22, 29))
86+
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
87+
>T : Symbol(T, Decl(file.tsx, 22, 25))
88+
89+
selectHandler: (selectedVal: T) => void;
90+
>selectHandler : Symbol(InferParamProp.selectHandler, Decl(file.tsx, 23, 21))
91+
>selectedVal : Symbol(selectedVal, Decl(file.tsx, 24, 20))
92+
>T : Symbol(T, Decl(file.tsx, 22, 25))
15293
}
15394

95+
declare function InferParamComponent<T>(attr: InferParamProp<T>): JSX.Element;
96+
>InferParamComponent : Symbol(InferParamComponent, Decl(file.tsx, 25, 1))
97+
>T : Symbol(T, Decl(file.tsx, 27, 37))
98+
>attr : Symbol(attr, Decl(file.tsx, 27, 40))
99+
>InferParamProp : Symbol(InferParamProp, Decl(file.tsx, 20, 1))
100+
>T : Symbol(T, Decl(file.tsx, 27, 37))
101+
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
102+
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
103+
104+
// OK
105+
let i = <InferParamComponent values={[1, 2, 3, 4]} selectHandler={(val) => { }} />;
106+
>i : Symbol(i, Decl(file.tsx, 30, 3))
107+
>InferParamComponent : Symbol(InferParamComponent, Decl(file.tsx, 25, 1))
108+
>values : Symbol(values, Decl(file.tsx, 30, 28))
109+
>selectHandler : Symbol(selectHandler, Decl(file.tsx, 30, 50))
110+
>val : Symbol(val, Decl(file.tsx, 30, 67))
154111

0 commit comments

Comments
 (0)