Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Conversation

@unstubbable
Copy link
Collaborator

Avoid anys in union types that are generated for oneOf with an array of identifiers, e.g.:

const FOO = 'foo';
const BAR = 'bar';
const fooOrBar = [FOO, BAR];

export default class SomeComponent extends React.Component {
   static propTypes = {
     someOneOf: React.PropTypes.oneOf(fooOrBar)
   };
}

now results in:

export type SomeComponentSomeOneOf = "foo" | "bar";

export interface SomeComponentProps {
  someOneOf?: SomeComponentSomeOneOf;
}

instead of:

export type SomeComponentSomeOneOf = any | any;

Copy link
Owner

@KnisterPeter KnisterPeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@unstubbable unstubbable merged commit ec98a14 into master Feb 7, 2018
@KnisterPeter KnisterPeter deleted the referenced-one-of-array-values branch February 7, 2018 16:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants