Is there any way to have a TypeScript enum compatible with strings from JSON?
For example:
enum Type { NEW, OLD }
interface Thing { type: Type }
l
but the type annotation string is way too broad and error prone.
Agreed. One quick workaround (if you have the luxury of code generation you can automate this):
interface Thing { type: "NEW" | "OLD" }
These are called string literals in a union. More : https://basarat.gitbooks.io/typescript/content/docs/tips/stringEnums.html