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

Issues with generic definitions #3

Closed
TheTFo opened this issue Jun 25, 2017 · 5 comments
Closed

Issues with generic definitions #3

TheTFo opened this issue Jun 25, 2017 · 5 comments

Comments

@TheTFo
Copy link
Contributor

TheTFo commented Jun 25, 2017

If I have definitions such as

Customer: { ... },
IPage[Customer]: { ... },
User: { ...  },
IPage[User] { ... }

This causes an error.

I attempted to solve this by putting in code to replace [ and ] with < and >, however flow doesn't appear to support exporting multiple generic implementations of a class.

export type Customer = {...};
export type IPage<Customer> = {...}
export type User = {...}
export type IPage<User> = {...}

I know this is a bit vague, but I didn't have time to scrub together an example. Hopefully this makes sense.

Another possible option, that's not too crazy, would be to drop the last bracket and replace the first with an underscore:

export type Customer = {...};
export type IPage_Customer = {...}
export type User = {...}
export type IPage_User = {...}

What are your thoughts? How does the swagger typescript generator handle this?

@yayoc
Copy link
Owner

yayoc commented Jun 26, 2017

This generator seems to just replace [ and ] with < and > and typescript also doesn't allow to declare duplicate generics. At this time, I think replacing [ and ] with < and > would be enough for this library.

@TheTFo
Copy link
Contributor Author

TheTFo commented Jun 26, 2017 via email

@TheTFo
Copy link
Contributor Author

TheTFo commented Jun 26, 2017

I checked at what https://github.com/swagger-api/swagger-codegen generates for typescript, they basically just remove the generic nature:

export interface IPageCustomer
export interface IPageUser

I can make this change, are you accepting PR's?

@yayoc
Copy link
Owner

yayoc commented Jun 26, 2017

Yes, please create PR.
@TheTFo

@TheTFo
Copy link
Contributor Author

TheTFo commented Jun 27, 2017

Pull Request #4 waiting to be reviewed.

@yayoc yayoc closed this as completed Jun 27, 2017
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

2 participants