Skip to content

Commit 8fde483

Browse files
authored
1 parent 4828c7a commit 8fde483

4 files changed

Lines changed: 200 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//// [index.tsx]
2+
namespace JSX {
3+
export interface Element {}
4+
}
5+
6+
export type CatInfo = { type: 'Cat'; subType: string; };
7+
export type DogInfo = { type: 'Dog'; };
8+
export type AnimalInfo = CatInfo | DogInfo;
9+
10+
function AnimalComponent(info: AnimalInfo): JSX.Element {
11+
return undefined as any;
12+
}
13+
14+
function getProps(): AnimalInfo {
15+
// this may be from server or whatever ...
16+
return { type: 'Cat', subType: 'Large' };
17+
}
18+
19+
var props:AnimalInfo = getProps();
20+
var component = <AnimalComponent {...props} />
21+
22+
var props2:AnimalInfo = { type: 'Cat', subType: 'Large' };
23+
var component2 = <AnimalComponent {...props2} />
24+
25+
//// [index.jsx]
26+
"use strict";
27+
exports.__esModule = true;
28+
function AnimalComponent(info) {
29+
return undefined;
30+
}
31+
function getProps() {
32+
// this may be from server or whatever ...
33+
return { type: 'Cat', subType: 'Large' };
34+
}
35+
var props = getProps();
36+
var component = <AnimalComponent {...props}/>;
37+
var props2 = { type: 'Cat', subType: 'Large' };
38+
var component2 = <AnimalComponent {...props2}/>;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
=== tests/cases/compiler/index.tsx ===
2+
namespace JSX {
3+
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
4+
5+
export interface Element {}
6+
>Element : Symbol(Element, Decl(index.tsx, 0, 15))
7+
}
8+
9+
export type CatInfo = { type: 'Cat'; subType: string; };
10+
>CatInfo : Symbol(CatInfo, Decl(index.tsx, 2, 1))
11+
>type : Symbol(type, Decl(index.tsx, 4, 23))
12+
>subType : Symbol(subType, Decl(index.tsx, 4, 36))
13+
14+
export type DogInfo = { type: 'Dog'; };
15+
>DogInfo : Symbol(DogInfo, Decl(index.tsx, 4, 56))
16+
>type : Symbol(type, Decl(index.tsx, 5, 23))
17+
18+
export type AnimalInfo = CatInfo | DogInfo;
19+
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
20+
>CatInfo : Symbol(CatInfo, Decl(index.tsx, 2, 1))
21+
>DogInfo : Symbol(DogInfo, Decl(index.tsx, 4, 56))
22+
23+
function AnimalComponent(info: AnimalInfo): JSX.Element {
24+
>AnimalComponent : Symbol(AnimalComponent, Decl(index.tsx, 6, 43))
25+
>info : Symbol(info, Decl(index.tsx, 8, 25))
26+
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
27+
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
28+
>Element : Symbol(JSX.Element, Decl(index.tsx, 0, 15))
29+
30+
return undefined as any;
31+
>undefined : Symbol(undefined)
32+
}
33+
34+
function getProps(): AnimalInfo {
35+
>getProps : Symbol(getProps, Decl(index.tsx, 10, 1))
36+
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
37+
38+
// this may be from server or whatever ...
39+
return { type: 'Cat', subType: 'Large' };
40+
>type : Symbol(type, Decl(index.tsx, 14, 12))
41+
>subType : Symbol(subType, Decl(index.tsx, 14, 25))
42+
}
43+
44+
var props:AnimalInfo = getProps();
45+
>props : Symbol(props, Decl(index.tsx, 17, 3))
46+
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
47+
>getProps : Symbol(getProps, Decl(index.tsx, 10, 1))
48+
49+
var component = <AnimalComponent {...props} />
50+
>component : Symbol(component, Decl(index.tsx, 18, 3))
51+
>AnimalComponent : Symbol(AnimalComponent, Decl(index.tsx, 6, 43))
52+
>props : Symbol(props, Decl(index.tsx, 17, 3))
53+
54+
var props2:AnimalInfo = { type: 'Cat', subType: 'Large' };
55+
>props2 : Symbol(props2, Decl(index.tsx, 20, 3))
56+
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
57+
>type : Symbol(type, Decl(index.tsx, 20, 25))
58+
>subType : Symbol(subType, Decl(index.tsx, 20, 38))
59+
60+
var component2 = <AnimalComponent {...props2} />
61+
>component2 : Symbol(component2, Decl(index.tsx, 21, 3))
62+
>AnimalComponent : Symbol(AnimalComponent, Decl(index.tsx, 6, 43))
63+
>props2 : Symbol(props2, Decl(index.tsx, 20, 3))
64+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
=== tests/cases/compiler/index.tsx ===
2+
namespace JSX {
3+
>JSX : any
4+
5+
export interface Element {}
6+
>Element : Element
7+
}
8+
9+
export type CatInfo = { type: 'Cat'; subType: string; };
10+
>CatInfo : CatInfo
11+
>type : "Cat"
12+
>subType : string
13+
14+
export type DogInfo = { type: 'Dog'; };
15+
>DogInfo : DogInfo
16+
>type : "Dog"
17+
18+
export type AnimalInfo = CatInfo | DogInfo;
19+
>AnimalInfo : AnimalInfo
20+
>CatInfo : CatInfo
21+
>DogInfo : DogInfo
22+
23+
function AnimalComponent(info: AnimalInfo): JSX.Element {
24+
>AnimalComponent : (info: AnimalInfo) => JSX.Element
25+
>info : AnimalInfo
26+
>AnimalInfo : AnimalInfo
27+
>JSX : any
28+
>Element : JSX.Element
29+
30+
return undefined as any;
31+
>undefined as any : any
32+
>undefined : undefined
33+
}
34+
35+
function getProps(): AnimalInfo {
36+
>getProps : () => AnimalInfo
37+
>AnimalInfo : AnimalInfo
38+
39+
// this may be from server or whatever ...
40+
return { type: 'Cat', subType: 'Large' };
41+
>{ type: 'Cat', subType: 'Large' } : { type: "Cat"; subType: string; }
42+
>type : string
43+
>'Cat' : "Cat"
44+
>subType : string
45+
>'Large' : "Large"
46+
}
47+
48+
var props:AnimalInfo = getProps();
49+
>props : AnimalInfo
50+
>AnimalInfo : AnimalInfo
51+
>getProps() : AnimalInfo
52+
>getProps : () => AnimalInfo
53+
54+
var component = <AnimalComponent {...props} />
55+
>component : any
56+
><AnimalComponent {...props} /> : any
57+
>AnimalComponent : (info: AnimalInfo) => JSX.Element
58+
>props : AnimalInfo
59+
60+
var props2:AnimalInfo = { type: 'Cat', subType: 'Large' };
61+
>props2 : AnimalInfo
62+
>AnimalInfo : AnimalInfo
63+
>{ type: 'Cat', subType: 'Large' } : { type: "Cat"; subType: string; }
64+
>type : string
65+
>'Cat' : "Cat"
66+
>subType : string
67+
>'Large' : "Large"
68+
69+
var component2 = <AnimalComponent {...props2} />
70+
>component2 : any
71+
><AnimalComponent {...props2} /> : any
72+
>AnimalComponent : (info: AnimalInfo) => JSX.Element
73+
>props2 : CatInfo
74+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// @jsx: preserve
2+
// @filename: index.tsx
3+
namespace JSX {
4+
export interface Element {}
5+
}
6+
7+
export type CatInfo = { type: 'Cat'; subType: string; };
8+
export type DogInfo = { type: 'Dog'; };
9+
export type AnimalInfo = CatInfo | DogInfo;
10+
11+
function AnimalComponent(info: AnimalInfo): JSX.Element {
12+
return undefined as any;
13+
}
14+
15+
function getProps(): AnimalInfo {
16+
// this may be from server or whatever ...
17+
return { type: 'Cat', subType: 'Large' };
18+
}
19+
20+
var props:AnimalInfo = getProps();
21+
var component = <AnimalComponent {...props} />
22+
23+
var props2:AnimalInfo = { type: 'Cat', subType: 'Large' };
24+
var component2 = <AnimalComponent {...props2} />

0 commit comments

Comments
 (0)