Open sindresorhus opened 3 years ago
Is the question here whether or not type-fest
should export Simplify
? I found this type and was hoping it was exported, since we have components that compose their props as below, and being able to flatten them for the editor would be really useful:
type Props = PropTypes.Position & PropTypes.Animation & {
componentSpecificProp: string,
...,
};
Even in its current state of only accepting object types it would be super useful, so I don't think exporting it should be dependent on adding more functionality.
The questions are not blocking. Anyone are free to submit a PR to expose it. 👍
Should it also support array like in https://gist.github.com/ClickerMonkey/a081b990b9b14215141fb6248cef4dc4#file-types-ts-L49-L54 ?
If there are no downsides from it, then I think it makes sense 👍 Though maybe await a use case in our code or a request for it? Else we may not even discover if it breaks eventually.
How can we test it?
We would probably have to go some odd route for this, like maybe pull out the language server itself and inspect the output?
Hello, I think that both Simplify and SimplifyDeep should also simplify arrays, currently this is not working:
type A = {
Prop: {
Prop1: string;
}[];
};
type B = {
Prop: {
Prop2: boolean;
}[];
};
type C = Simplify<A & B>;
type C = SimplifyDeep<A & B>;
Both produce a type like this:
type C = {
Prop: {
Prop1: string;
}[] & {
Prop2: boolean;
}[];
}
I think https://github.com/sindresorhus/type-fest/pull/157/files#diff-520a63fe400b4b92fa3ccc14cabc1d84153987354c3f242deddfaeff0a7deae2 could be useful for others too.
Upvote & Fund