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
Use case: I have a type JSONValue (which I’ve seen before in some DefinitelyTyped libraries) to make sure an object is a valid JSON value. Which would mean it doesn’t contain functions or other problematic properties.
I also have some interfaces which inherit from each other using extends which should be valid JSON values. Which is why I would prefer to use an interface over an object type in this case.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 3.3.3
Search Terms: index signature, interface, object type
Code
Expected behavior: Both
a
should be assignable tojsonA
andb
should be assignable tojsonB
.Actual behavior:
jsonA = a
errs butjsonB = b
does not err.Playground Link
Use case: I have a type
JSONValue
(which I’ve seen before in some DefinitelyTyped libraries) to make sure an object is a valid JSON value. Which would mean it doesn’t contain functions or other problematic properties.I also have some interfaces which inherit from each other using
extends
which should be valid JSON values. Which is why I would prefer to use an interface over an object type in this case.The text was updated successfully, but these errors were encountered: