Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ Triggers the closest error boundary if the document cannot be found

| Function | Type |
| ---------- | ---------- |
| `useSingleDocByDocId` | `<D extends WriteableDocumentType>({ projectId, docType, docId, lang, }: { projectId: string; docType: D; docId: string; lang?: string or undefined; }) => Pick<UseSuspenseQueryResult<Awaited<ReturnType<ClientApi<MapeoProject>[D]["getByDocId"]>>>, "data" or ... 1 more ... or "isRefetching">` |
| `useSingleDocByDocId` | `<D extends WriteableDocumentType>({ projectId, docType, docId, lang, }: { projectId: string; docType: D; docId: string; lang?: string or undefined; }) => Pick<UseSuspenseQueryResult<NonNullable<Awaited<ReturnType<ClientApi<MapeoProject>[D]["getByDocId"]>>>>, "data" or ... 1 more ... or "isRefetching">` |

Parameters:

Expand Down
5 changes: 4 additions & 1 deletion src/hooks/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export function useSingleDocByDocId<D extends WriteableDocumentType>({
lang?: string
}): // NOTE: Needs explicit return type due to TS struggles with inference
Pick<
UseSuspenseQueryResult<Awaited<ReturnType<MapeoProjectApi[D]['getByDocId']>>>,
UseSuspenseQueryResult<
// NOTE: Using NonNullable here to get the return type associated with the overload that uses `mustBeFound: true`
NonNullable<Awaited<ReturnType<MapeoProjectApi[D]['getByDocId']>>>
>,
'data' | 'error' | 'isRefetching'
> {
const { data: projectApi } = useSingleProject({ projectId })
Expand Down
Loading