Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Simplify type? #172

Open
3 tasks
sindresorhus opened this issue Dec 16, 2020 · 4 comments
Open
3 tasks

Improve Simplify type? #172

sindresorhus opened this issue Dec 16, 2020 · 4 comments

Comments

@sindresorhus
Copy link
Owner

sindresorhus commented Dec 16, 2020

I think https://github.com/sindresorhus/type-fest/pull/157/files#diff-520a63fe400b4b92fa3ccc14cabc1d84153987354c3f242deddfaeff0a7deae2 could be useful for others too.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@ianobermiller
Copy link
Contributor

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.

@sindresorhus
Copy link
Owner Author

The questions are not blocking. Anyone are free to submit a PR to expose it. 👍

ianobermiller added a commit to ianobermiller/type-fest that referenced this issue Jul 30, 2021
Per sindresorhus#172, export the Simplify util so it can be used to flatten type intersections for better IDE tooltips.
@sindresorhus sindresorhus changed the title Proposal: Simplify Improve Simplify type? Jul 31, 2021
@voxpelli
Copy link
Collaborator

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?

@Xriuk
Copy link

Xriuk commented May 20, 2024

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;
    }[];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants