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

Fix factory types #1011

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

wagenet
Copy link
Contributor

@wagenet wagenet commented Dec 2, 2021

No description provided.

@@ -181,7 +181,7 @@ declare module "miragejs/-types" {
}

type WithFactoryMethods<T> = {
[K in keyof T]: T[K] | ((n: number) => T[K]);
[K in keyof T]: T[K] | ((this: FlattenFactoryMethods<T>, n: number) => T[K]);
Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly does this do?

As I understand it, it takes a factory and translates method return types into basic types, so

{
    age: number;
    height: () => string;
}

becomes

{
    age: number;
    height: string;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe that is correct.

@wagenet
Copy link
Contributor Author

wagenet commented Jun 27, 2022

Unfortunately, there's still a lot of messiness around types in Mirage. I'm not sure whether it's still worth merging this so if someone thinks it's good to close, that's ok with me.

@IanVS
Copy link
Collaborator

IanVS commented Jun 28, 2022

Thanks for taking a crack at this, @wagenet. I'd love to get the types cleaned up, but if I recall correctly, this PR had some failing type tests. If you're willing to work on them and get them passing, I'll be happy to review.

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

Successfully merging this pull request may close these issues.

None yet

3 participants