fix: indicate that required properties are not null#50
Open
ColinEberhardt wants to merge 1 commit intomainfrom
Open
fix: indicate that required properties are not null#50ColinEberhardt wants to merge 1 commit intomainfrom
ColinEberhardt wants to merge 1 commit intomainfrom
Conversation
|
I'm wondering if creating a constructor method would be better here, thinking from the perspective of extending classes. Honestly not sure if that's a likely use case or not, might just be my preference seeping through. |
Collaborator
Author
|
Thanks for the suggestion @OiNutter - a potential alternative. Although using a constructor method would make the deserialization process more challenging. Currently an empty constructor is used, with properties set after construction: I might experiment a bit with the constructor function approach. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code which is generated results in the following errors:
Because the model objects are deserialised from JSON, it is not possible to create TS classes that demonstrate to the compiler that these properties are always set.
This change uses the null assertion operator to indicate that this value is not null:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#non-null-assertion-operator