Description
Given a union like type C = A | B, where A and B are both interfaces, babel-plugin-typescript-to-prototype generates code requiring that C contain all values present in A and B, rather than values present in either A or B. For example:
import React from 'react';
interface A {
foo: string;
}
interface B {
bar: string;
}
type C = A | B;
export const Component = (_props: C) => {
return <React.Fragment></React.Fragment>;
}
This will generate the following code:
var Component = function Component(_props) {
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
};
exports.Component = Component;
Component.propTypes = {
foo: _propTypes["default"].string.isRequired,
bar: _propTypes["default"].string.isRequired
};
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:
var Component = function Component(_props) {
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
};
exports.Component = Component;
Component.propTypes = _propTypes["default"].oneOfType([
_propTypes["default"].shape({
foo: _propTypes["default"].string.isRequired,
}),
_propTypes["default"].shape({
bar: _propTypes["default"].string.isRequired
}),
]).isRequired;
Description
Given a union like
type C = A | B, whereAandBare both interfaces, babel-plugin-typescript-to-prototype generates code requiring thatCcontain all values present inAandB, rather than values present in eitherAorB. 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: