diff --git a/tests/baselines/reference/tsxUnionSpread.js b/tests/baselines/reference/tsxUnionSpread.js new file mode 100644 index 0000000000..f84e6ab216 --- /dev/null +++ b/tests/baselines/reference/tsxUnionSpread.js @@ -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 = + +var props2:AnimalInfo = { type: 'Cat', subType: 'Large' }; +var component2 = + +//// [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 = ; +var props2 = { type: 'Cat', subType: 'Large' }; +var component2 = ; diff --git a/tests/baselines/reference/tsxUnionSpread.symbols b/tests/baselines/reference/tsxUnionSpread.symbols new file mode 100644 index 0000000000..fa838773a8 --- /dev/null +++ b/tests/baselines/reference/tsxUnionSpread.symbols @@ -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 = +>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 = +>component2 : Symbol(component2, Decl(index.tsx, 21, 3)) +>AnimalComponent : Symbol(AnimalComponent, Decl(index.tsx, 6, 43)) +>props2 : Symbol(props2, Decl(index.tsx, 20, 3)) + diff --git a/tests/baselines/reference/tsxUnionSpread.types b/tests/baselines/reference/tsxUnionSpread.types new file mode 100644 index 0000000000..11e6308fe1 --- /dev/null +++ b/tests/baselines/reference/tsxUnionSpread.types @@ -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 = +>component : any +> : 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 = +>component2 : any +> : any +>AnimalComponent : (info: AnimalInfo) => JSX.Element +>props2 : CatInfo + diff --git a/tests/cases/compiler/tsxUnionSpread.tsx b/tests/cases/compiler/tsxUnionSpread.tsx new file mode 100644 index 0000000000..daa663db87 --- /dev/null +++ b/tests/cases/compiler/tsxUnionSpread.tsx @@ -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 = + +var props2:AnimalInfo = { type: 'Cat', subType: 'Large' }; +var component2 = \ No newline at end of file