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
In the first two, I've defined them in terms of mapped types with a concrete key of string, and an object type with a string index signature. TypeScript has no issues with either of those.
On the other hand, the last two are described with Record, or with a helper mapped type fed in a string key type.
// No errors ✅namespaceObjectIsMappedTypeOnString{exporttypeJson=|string|number|boolean|null|Json[]|{[Kinstring]: Json};}// No errors ✅namespaceObjectIsIndexSignature{exporttypeJson=|string|number|boolean|null|Json[]|{[key: string]: Json};}// Errors ❌namespaceObjectIsRecord{exporttypeJson=|string|number|boolean|null|Json[]|Record<string,Json>;}// Error ❌namespaceObjectIsGenericMappedType{typeJsonProperties<KextendsPropertyKey>={[PinK]: Json};exporttypeJson=|string|number|boolean|null|Json[]|JsonProperties<Json>;}
I would expect all of these to work.
The text was updated successfully, but these errors were encountered:
In the following examples, I've defined 4 different versions of a
Json
type, where they differ on their description of object types.Playground link here.
In the first two, I've defined them in terms of mapped types with a concrete key of string, and an object type with a
string
index signature. TypeScript has no issues with either of those.On the other hand, the last two are described with
Record
, or with a helper mapped type fed in astring
key type.I would expect all of these to work.
The text was updated successfully, but these errors were encountered: