You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is being filed after some discussion with @endel in Discord. Some of the bug will be a rehash of that discussion.
Background
I'm working on a TypeScript-based game. I experimented with using schema-codegen to produce TypeScript output so that my client could know the type of room.state as it is defined in the corresponding server modules.
Problem
The generated classes are missing initializers for fields with primitive types. For example, given the input:
@endel pointed out that if I could afford to consume the Schema-based classes as a shared module, it would not be necessary to use schema-codegen to produce a client version. This is what I decided to do, and it made a lot of sense to me because it gives me the most flexibility with my tsconfig.json settings.
After some discussion with @endel he suggested that this code might compile if "strictNullChecks": false is set in tsconfig.json. So, perhaps all that is needed is a note about this in the README (apologies if I missed an existing note about this).
Yet another remedy would be to change the TypeScript output produced by schema-codegen, either to make it more faithfully reflect the source it was generated from, or to at least make it more likely to be compiled by a wider range of tsconfig.json configurations.
Thanks a lot for the help so far, and I look forward to discussion about this issue.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
This issue is being filed after some discussion with @endel in Discord. Some of the bug will be a rehash of that discussion.
Background
I'm working on a TypeScript-based game. I experimented with using
schema-codegen
to produce TypeScript output so that my client could know the type ofroom.state
as it is defined in the corresponding server modules.Problem
The generated classes are missing initializers for fields with primitive types. For example, given the input:
I get the following generated output:
See how the initializers are removed from the
turn
andwaitingForPlayers
fields? The main problem with this output is that it isn't valid TypeScript (or at least, not for basic configurations of the TypeScript compiler). For example, consider this trivial case: https://www.typescriptlang.org/play?#code/MYGwhgzhAEBiD29oG8BQ0PQA4FcBGIAlsNHmAE4Bc0AdjgLZ4Cm5A3KgL5APotential remedies
@endel pointed out that if I could afford to consume the
Schema
-based classes as a shared module, it would not be necessary to useschema-codegen
to produce a client version. This is what I decided to do, and it made a lot of sense to me because it gives me the most flexibility with mytsconfig.json
settings.After some discussion with @endel he suggested that this code might compile if
"strictNullChecks": false
is set intsconfig.json
. So, perhaps all that is needed is a note about this in the README (apologies if I missed an existing note about this).Yet another remedy would be to change the TypeScript output produced by
schema-codegen
, either to make it more faithfully reflect the source it was generated from, or to at least make it more likely to be compiled by a wider range oftsconfig.json
configurations.Thanks a lot for the help so far, and I look forward to discussion about this issue.
The text was updated successfully, but these errors were encountered: