Open ianhoffman opened 2 years ago
@ianhoffman This doesn't support props as a union, since when extracted, the prop types are simply a list of all possible fields: https://github.com/milesj/babel-plugin-typescript-to-proptypes/blob/master/src/addToClass.ts#L36
I don't really maintain this anymore, so I won't be fixing this, but feel free to submit a PR.
Thanks for the quick response. This looks like it'll require a pretty fundamental change to the way the plugin generates prop types (at least if we want to support things beyond the simplest case, e.g., A & (B | C)
). I'm probably going to table working on it.
Description
Given a union like
type C = A | B
, whereA
andB
are both interfaces, babel-plugin-typescript-to-prototype generates code requiring thatC
contain all values present inA
andB
, rather than values present in eitherA
orB
. For example:This will generate the following code:
For a full repro, see https://github.com/ianhoffman/union-bug-repro
Expected Behavior
Given the above example, we should generate something like the following: