Skip to content

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-l committed Jul 4, 2018
1 parent 704f5d9 commit 87a0818
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,25 @@ ruleTester.run('prop-types', rule, {
};
`,
parser: 'babel-eslint'
},
{
code: `
// @flow
import * as React from 'react'
type Props = {}
const func = <OP: *>(arg) => arg
const hoc = <OP>() => () => {
class Inner extends React.Component<Props & OP> {
render() {
return <div />
}
}
}
`,
parser: 'babel-eslint'
}
],

Expand Down Expand Up @@ -3627,6 +3646,38 @@ ruleTester.run('prop-types', rule, {
message: '\'fooBar\' is missing in props validation'
}],
parser: 'babel-eslint'
},
{
code: `
type ReduxState = {bar: number};
const mapStateToProps = (state: ReduxState) => ({
foo: state.bar,
});
// utility to extract the return type from a function
type ExtractReturn_<R, Fn: (...args: any[]) => R> = R;
type ExtractReturn<T> = ExtractReturn_<*, T>;
type PropsFromRedux = ExtractReturn<typeof mapStateToProps>;
type OwnProps = {
baz: string,
}
// I want my Props to be {baz: string, foo: number}
type Props = PropsFromRedux & OwnProps;
const Component = (props: Props) => (
<div>
{props.baz}
{props.bad}
</div>
);
`,
errors: [{
message: '\'bad\' is missing in props validation'
}],
parser: 'babel-eslint'
}
]
});

0 comments on commit 87a0818

Please sign in to comment.