Open earthlyreason opened 4 years ago
The JSON:API spec says:
Primary data MUST be either: a single resource object, a single resource identifier object, or null, for requests that target single resources an array of resource objects, an array of resource identifier objects, or an empty array ([]), for requests that target resource collections
Primary data MUST be either:
null
Note "or null" in the first condition.
So the following code should typecheck:
export const doc: JSONAPI.Document = { data: null };
Instead, it gives the following error:
Type 'null' is not assignable to type 'PrimaryData<string, AttributesObject<{ [k: string]: Value; }>>'. [2322]
This is because the PrimaryData type, which is used as the type of data in DocWithData is an interface that assumes the value is an existing object.
PrimaryData
data
DocWithData
Is this intentional?
Expected behavior The above should typecheck, but it gives the indicated error.
System Information (please complete the following information):
The JSON:API spec says:
Note "or
null
" in the first condition.So the following code should typecheck:
Instead, it gives the following error:
This is because the
PrimaryData
type, which is used as the type ofdata
inDocWithData
is an interface that assumes the value is an existing object.Is this intentional?
Expected behavior The above should typecheck, but it gives the indicated error.
System Information (please complete the following information):