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
I have JSON files containing NHL roster data. Each player object has a positionCode property and a shootsCatches property:
The positionCode property can be one of "L", "C", "R", "D", or "G".
The shootsCatches property can only be "L" or "R".
It's important to note here that "L" and "R" overlap between these two properties.
When I convert the JSON to TypeScript using Quicktype, the resulting type for the positionCode property is:
exporttypePositionCode="L"|"C"|"R"|"D"|"G";
This part is correct, as it reflects all possible values for positionCode. However, Quicktype incorrectly assigns the same union type to the shootsCatches property, which should only allow "L" or "R".
Input Data
To generate the input data:
Create a folder called json inside the root of a Node.js project.
Issue Type
Quicktype output
Context (Environment, Version, Language)
Description
I have JSON files containing NHL roster data. Each player object has a
positionCode
property and ashootsCatches
property:positionCode
property can be one of"L"
,"C"
,"R"
,"D"
, or"G"
.shootsCatches
property can only be"L"
or"R"
.It's important to note here that
"L"
and"R"
overlap between these two properties.When I convert the JSON to TypeScript using Quicktype, the resulting type for the
positionCode
property is:This part is correct, as it reflects all possible values for
positionCode
. However, Quicktype incorrectly assigns the same union type to theshootsCatches
property, which should only allow"L"
or"R"
.Input Data
To generate the input data:
json
inside the root of a Node.js project.Command to generate output
quicktype json/*.json --top-level Root --lang typescript --just-types --prefer-types --prefer-const-values --prefer-unions -o generated-types.ts
Expected Behaviour / Output
I expect
positionCode
andshootsCatches
to be seperate union types.Current Behaviour / Output
The text was updated successfully, but these errors were encountered: