This commit is contained in:
Wesley Wigham 2017-08-10 00:10:36 -07:00 committed by GitHub
parent 4828c7a62b
commit 8fde483393
4 changed files with 200 additions and 0 deletions

View file

@ -0,0 +1,38 @@
//// [index.tsx]
namespace JSX {
export interface Element {}
}
export type CatInfo = { type: 'Cat'; subType: string; };
export type DogInfo = { type: 'Dog'; };
export type AnimalInfo = CatInfo | DogInfo;
function AnimalComponent(info: AnimalInfo): JSX.Element {
return undefined as any;
}
function getProps(): AnimalInfo {
// this may be from server or whatever ...
return { type: 'Cat', subType: 'Large' };
}
var props:AnimalInfo = getProps();
var component = <AnimalComponent {...props} />
var props2:AnimalInfo = { type: 'Cat', subType: 'Large' };
var component2 = <AnimalComponent {...props2} />
//// [index.jsx]
"use strict";
exports.__esModule = true;
function AnimalComponent(info) {
return undefined;
}
function getProps() {
// this may be from server or whatever ...
return { type: 'Cat', subType: 'Large' };
}
var props = getProps();
var component = <AnimalComponent {...props}/>;
var props2 = { type: 'Cat', subType: 'Large' };
var component2 = <AnimalComponent {...props2}/>;

View file

@ -0,0 +1,64 @@
=== tests/cases/compiler/index.tsx ===
namespace JSX {
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
export interface Element {}
>Element : Symbol(Element, Decl(index.tsx, 0, 15))
}
export type CatInfo = { type: 'Cat'; subType: string; };
>CatInfo : Symbol(CatInfo, Decl(index.tsx, 2, 1))
>type : Symbol(type, Decl(index.tsx, 4, 23))
>subType : Symbol(subType, Decl(index.tsx, 4, 36))
export type DogInfo = { type: 'Dog'; };
>DogInfo : Symbol(DogInfo, Decl(index.tsx, 4, 56))
>type : Symbol(type, Decl(index.tsx, 5, 23))
export type AnimalInfo = CatInfo | DogInfo;
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
>CatInfo : Symbol(CatInfo, Decl(index.tsx, 2, 1))
>DogInfo : Symbol(DogInfo, Decl(index.tsx, 4, 56))
function AnimalComponent(info: AnimalInfo): JSX.Element {
>AnimalComponent : Symbol(AnimalComponent, Decl(index.tsx, 6, 43))
>info : Symbol(info, Decl(index.tsx, 8, 25))
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
>Element : Symbol(JSX.Element, Decl(index.tsx, 0, 15))
return undefined as any;
>undefined : Symbol(undefined)
}
function getProps(): AnimalInfo {
>getProps : Symbol(getProps, Decl(index.tsx, 10, 1))
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
// this may be from server or whatever ...
return { type: 'Cat', subType: 'Large' };
>type : Symbol(type, Decl(index.tsx, 14, 12))
>subType : Symbol(subType, Decl(index.tsx, 14, 25))
}
var props:AnimalInfo = getProps();
>props : Symbol(props, Decl(index.tsx, 17, 3))
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
>getProps : Symbol(getProps, Decl(index.tsx, 10, 1))
var component = <AnimalComponent {...props} />
>component : Symbol(component, Decl(index.tsx, 18, 3))
>AnimalComponent : Symbol(AnimalComponent, Decl(index.tsx, 6, 43))
>props : Symbol(props, Decl(index.tsx, 17, 3))
var props2:AnimalInfo = { type: 'Cat', subType: 'Large' };
>props2 : Symbol(props2, Decl(index.tsx, 20, 3))
>AnimalInfo : Symbol(AnimalInfo, Decl(index.tsx, 5, 39))
>type : Symbol(type, Decl(index.tsx, 20, 25))
>subType : Symbol(subType, Decl(index.tsx, 20, 38))
var component2 = <AnimalComponent {...props2} />
>component2 : Symbol(component2, Decl(index.tsx, 21, 3))
>AnimalComponent : Symbol(AnimalComponent, Decl(index.tsx, 6, 43))
>props2 : Symbol(props2, Decl(index.tsx, 20, 3))

View file

@ -0,0 +1,74 @@
=== tests/cases/compiler/index.tsx ===
namespace JSX {
>JSX : any
export interface Element {}
>Element : Element
}
export type CatInfo = { type: 'Cat'; subType: string; };
>CatInfo : CatInfo
>type : "Cat"
>subType : string
export type DogInfo = { type: 'Dog'; };
>DogInfo : DogInfo
>type : "Dog"
export type AnimalInfo = CatInfo | DogInfo;
>AnimalInfo : AnimalInfo
>CatInfo : CatInfo
>DogInfo : DogInfo
function AnimalComponent(info: AnimalInfo): JSX.Element {
>AnimalComponent : (info: AnimalInfo) => JSX.Element
>info : AnimalInfo
>AnimalInfo : AnimalInfo
>JSX : any
>Element : JSX.Element
return undefined as any;
>undefined as any : any
>undefined : undefined
}
function getProps(): AnimalInfo {
>getProps : () => AnimalInfo
>AnimalInfo : AnimalInfo
// this may be from server or whatever ...
return { type: 'Cat', subType: 'Large' };
>{ type: 'Cat', subType: 'Large' } : { type: "Cat"; subType: string; }
>type : string
>'Cat' : "Cat"
>subType : string
>'Large' : "Large"
}
var props:AnimalInfo = getProps();
>props : AnimalInfo
>AnimalInfo : AnimalInfo
>getProps() : AnimalInfo
>getProps : () => AnimalInfo
var component = <AnimalComponent {...props} />
>component : any
><AnimalComponent {...props} /> : any
>AnimalComponent : (info: AnimalInfo) => JSX.Element
>props : AnimalInfo
var props2:AnimalInfo = { type: 'Cat', subType: 'Large' };
>props2 : AnimalInfo
>AnimalInfo : AnimalInfo
>{ type: 'Cat', subType: 'Large' } : { type: "Cat"; subType: string; }
>type : string
>'Cat' : "Cat"
>subType : string
>'Large' : "Large"
var component2 = <AnimalComponent {...props2} />
>component2 : any
><AnimalComponent {...props2} /> : any
>AnimalComponent : (info: AnimalInfo) => JSX.Element
>props2 : CatInfo

View file

@ -0,0 +1,24 @@
// @jsx: preserve
// @filename: index.tsx
namespace JSX {
export interface Element {}
}
export type CatInfo = { type: 'Cat'; subType: string; };
export type DogInfo = { type: 'Dog'; };
export type AnimalInfo = CatInfo | DogInfo;
function AnimalComponent(info: AnimalInfo): JSX.Element {
return undefined as any;
}
function getProps(): AnimalInfo {
// this may be from server or whatever ...
return { type: 'Cat', subType: 'Large' };
}
var props:AnimalInfo = getProps();
var component = <AnimalComponent {...props} />
var props2:AnimalInfo = { type: 'Cat', subType: 'Large' };
var component2 = <AnimalComponent {...props2} />