Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests and baselines
  • Loading branch information
Kanchalai Tanglertsampan committed Aug 15, 2016
commit 5f88566f652acf95e43cd00777e72eff7c551a4b
38 changes: 38 additions & 0 deletions tests/baselines/reference/tsxAttributeResolution14.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
tests/cases/conformance/jsx/file.tsx(14,28): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type 'boolean' is not assignable to type 'string | number'.


==== tests/cases/conformance/jsx/react.d.ts (0 errors) ====

declare module JSX {
interface Element { }
interface IntrinsicElements {
div: any;
}
interface ElementAttributesProperty { prop: any }
}

==== tests/cases/conformance/jsx/file.tsx (2 errors) ====

interface IProps {
primaryText: string,
[propName: string]: string | number
}

function VerticalNavMenuItem(prop: IProps) {
return <div>props.primaryText</div>
}

function VerticalNav() {
return (
<div>
<VerticalNavMenuItem primaryText={2} /> // error
~~~~~~~~~~~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
<VerticalNavMenuItem justRandomProp={2} primaryText={"hello"} /> // ok
<VerticalNavMenuItem justRandomProp1={true} primaryText={"hello"} /> // error
~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'.
</div>
)
}
47 changes: 47 additions & 0 deletions tests/baselines/reference/tsxAttributeResolution14.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//// [tests/cases/conformance/jsx/tsxAttributeResolution14.tsx] ////

//// [react.d.ts]

declare module JSX {
interface Element { }
interface IntrinsicElements {
div: any;
}
interface ElementAttributesProperty { prop: any }
}

//// [file.tsx]

interface IProps {
primaryText: string,
[propName: string]: string | number
}

function VerticalNavMenuItem(prop: IProps) {
return <div>props.primaryText</div>
}

function VerticalNav() {
return (
<div>
<VerticalNavMenuItem primaryText={2} /> // error
<VerticalNavMenuItem justRandomProp={2} primaryText={"hello"} /> // ok
<VerticalNavMenuItem justRandomProp1={true} primaryText={"hello"} /> // error
</div>
)
}

//// [file.jsx]
function VerticalNavMenuItem(prop) {
return <div>props.primaryText</div>;
}
function VerticalNav() {
return (<div>
<VerticalNavMenuItem primaryText={2}/> // error
// error
<VerticalNavMenuItem justRandomProp={2} primaryText={"hello"}/> // ok
// ok
<VerticalNavMenuItem justRandomProp1={true} primaryText={"hello"}/> // error
// error
</div>);
}
32 changes: 32 additions & 0 deletions tests/cases/conformance/jsx/tsxAttributeResolution14.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//@jsx: preserve
//@module: amd

//@filename: react.d.ts
declare module JSX {
interface Element { }
interface IntrinsicElements {
div: any;
}
interface ElementAttributesProperty { prop: any }
}

//@filename: file.tsx

interface IProps {
primaryText: string,
[propName: string]: string | number
}

function VerticalNavMenuItem(prop: IProps) {
return <div>props.primaryText</div>
}

function VerticalNav() {
return (
<div>
<VerticalNavMenuItem primaryText={2} /> // error
<VerticalNavMenuItem justRandomProp={2} primaryText={"hello"} /> // ok
<VerticalNavMenuItem justRandomProp1={true} primaryText={"hello"} /> // error
</div>
)
}