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
// The members data and errors MUST NOT coexist in the same document.
// ⛔️ NOT EXPRESSIBLE IN TYPESCRIPT
// If a document does not contain a top-level data key,
// the included member MUST NOT be present either.
// ⛔️ NOT EXPRESSIBLE IN TYPESCRIPT
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
interface DocWithDataAndOptionalMeta extends DocWithData{
meta?: object;
}
interface DocWithErrorsAndOptionalMeta extends DocWithErrors {
meta?: object;
}
type JSONAPIDocument = XOR<DocWithErrorsAndOptionalMeta, DocWithDataAndOptionalMeta>;
I believe gets you what we want. I can open a PR, was just not certain about how to handle meta. It seems fine to have meta included in a top level response w/errors present or with a 'normal' doc
The text was updated successfully, but these errors were encountered:
This is great! I'll need us to do some performance testing since this increases the complexity of all JSONAPI resource types (i.e., "document with data") significantly.
Describe the bug
is not true any longer
To Reproduce
is valid and should not be
Additional context
I believe gets you what we want. I can open a PR, was just not certain about how to handle meta. It seems fine to have meta included in a top level response w/errors present or with a 'normal' doc
The text was updated successfully, but these errors were encountered: