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

In the TypeScript Generator, the generated code has to be tweaked to add defaults to required properties. #49

Open
ms14981 opened this issue Apr 5, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@ms14981
Copy link
Contributor

ms14981 commented Apr 5, 2023

Using the pet store example, when first trying to run it, you get:

model.ts(250,10): error TS2564: Property 'name' has no initializer and is not definitely assigned in the constructor.
model.ts(252,10): error TS2564: Property 'photoUrls' has no initializer and is not definitely assigned in the constructor.

These are required properties. Is there a way we can prevent these errors? Adding a tsconfig.json to the generated code is one option: https://stackoverflow.com/a/50241920/

@ColinEberhardt
Copy link
Collaborator

Good point - I think a better solution is to use the not-null assertion operator:

#50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants