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
When importing from a json file, some type information seems to be lost. Would it be worth to keep the strictest type information about the imported type? Eg.: in the example instead of inferring the { type: string } maybe infer { type: "frog" } instead?
Compile error: Type '{ "type": string; }' is not assignable to type 'Animal'.
Types of property 'type' are incompatible.
Type 'string' is not assignable to type 'AnimalType'.
The text was updated successfully, but these errors were encountered:
When importing from a json file, some type information seems to be lost. Would it be worth to keep the strictest type information about the imported type? Eg.: in the example instead of inferring the
{ type: string }
maybe infer{ type: "frog" }
instead?TypeScript Version: 3.0.3
Search Terms:
json import string union type
Code
sample.json
sample.ts
Expected behavior:
No compliation error
Actual behavior:
The text was updated successfully, but these errors were encountered: