Skip to content

Commit 778a63a

Browse files
authored
fix: fix typedoc annotations for hooks (#361)
* fix: fix typedoc annotations for hooks: - adds @function tag for hooks exported as constants - adds @interface for ProjectWithoutMembers type to expand dynamic properties - corrects mention of which datasets returned by useDatasets - corrects mention of which projects returned by useProjects * fix: add missing tsdoc tag definitions * fix: add missing custom tsdoc tags * fix: useDocuments->useInfiniteList in usePreview example
1 parent c753897 commit 778a63a

File tree

12 files changed

+88
-15
lines changed

12 files changed

+88
-15
lines changed

packages/@repo/package.config/src/package.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ export const basePackageConfig = defineConfig({
2828
allowMultiple: true,
2929
syntaxKind: 'block',
3030
},
31+
{
32+
name: 'function',
33+
allowMultiple: false,
34+
syntaxKind: 'modifier',
35+
},
36+
{
37+
name: 'interface',
38+
syntaxKind: 'modifier',
39+
allowMultiple: false,
40+
},
3141
],
3242
},
3343
})

packages/core/src/tsdoc.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
"tagName": "@thoughtLevel",
1616
"syntaxKind": "block",
1717
"allowMultiple": true
18+
},
19+
{
20+
"tagName": "@interface",
21+
"syntaxKind": "modifier",
22+
"allowMultiple": false
23+
},
24+
{
25+
"tagName": "@function",
26+
"syntaxKind": "modifier",
27+
"allowMultiple": false
1828
}
1929
],
2030
"supportForTags": {
@@ -34,6 +44,8 @@
3444
"@see": true,
3545
"@thoughtLevel": true,
3646
"@throws": true,
37-
"@todo": true
47+
"@todo": true,
48+
"@interface": true,
49+
"@function": true
3850
}
3951
}

packages/core/tsdoc.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
"tagName": "@category",
1616
"syntaxKind": "block",
1717
"allowMultiple": true
18+
},
19+
{
20+
"tagName": "@function",
21+
"syntaxKind": "modifier",
22+
"allowMultiple": false
23+
},
24+
{
25+
"tagName": "@interface",
26+
"syntaxKind": "modifier",
27+
"allowMultiple": false
1828
}
1929
],
2030
"supportForTags": {
@@ -34,6 +44,8 @@
3444
"@throws": true,
3545
"@defaultValue": true,
3646
"@todo": true,
37-
"@category": true
47+
"@category": true,
48+
"@function": true,
49+
"@interface": true
3850
}
3951
}

packages/react-internal/tsdoc.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
"tagName": "@todo",
1111
"syntaxKind": "block",
1212
"allowMultiple": true
13+
},
14+
{
15+
"tagName": "@function",
16+
"syntaxKind": "modifier",
17+
"allowMultiple": false
18+
},
19+
{
20+
"tagName": "@interface",
21+
"syntaxKind": "modifier",
22+
"allowMultiple": false
1323
}
1424
],
1525
"supportForTags": {
@@ -28,6 +38,8 @@
2838
"@remarks": true,
2939
"@throws": true,
3040
"@defaultValue": true,
31-
"@todo": true
41+
"@todo": true,
42+
"@function": true,
43+
"@interface": true
3244
}
3345
}

packages/react/src/hooks/auth/useCurrentUser.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type UseCurrentUser = {
2828

2929
/**
3030
* @public
31+
* @function
3132
* @TODO This should not return null — users of a custom app will always be authenticated via Core
3233
*/
3334
export const useCurrentUser: UseCurrentUser = createStateSourceHook(getCurrentUserState)

packages/react/src/hooks/client/useClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {createStateSourceHook} from '../helpers/createStateSourceHook'
2727
* ```
2828
*
2929
* @public
30+
* @function
3031
*/
3132
export const useClient = createStateSourceHook({
3233
getState: getClientState,

packages/react/src/hooks/datasets/useDatasets.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {createStateSourceHook} from '../helpers/createStateSourceHook'
66
type UseDatasets = {
77
/**
88
*
9-
* Returns metadata for each dataset in your organization.
9+
* Returns metadata for each dataset the current user has access to.
1010
*
1111
* @category Datasets
12-
* @returns The metadata for your organization's datasets
12+
* @returns The metadata for your the datasets
1313
*
1414
* @example
1515
* ```tsx
@@ -28,7 +28,10 @@ type UseDatasets = {
2828
(): DatasetsResponse
2929
}
3030

31-
/** @public */
31+
/**
32+
* @public
33+
* @function
34+
*/
3235
export const useDatasets: UseDatasets = createStateSourceHook({
3336
// remove `undefined` since we're suspending when that is the case
3437
getState: getDatasetsState as (instance: SanityInstance) => StateSource<DatasetsResponse>,

packages/react/src/hooks/document/useDocumentSyncStatus.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ type UseDocumentSyncStatus = {
2525
(doc: DocumentHandle): boolean | undefined
2626
}
2727

28-
/** @beta */
28+
/**
29+
* @beta
30+
* @function
31+
*/
2932
export const useDocumentSyncStatus: UseDocumentSyncStatus =
3033
createStateSourceHook(getDocumentSyncStatus)

packages/react/src/hooks/preview/usePreview.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface UsePreviewResults {
3636
* @param options - The document handle for the document you want to resolve preview values for, and an optional ref
3737
* @returns The preview values for the given document and a boolean to indicate whether the resolution is pending
3838
*
39-
* @example Combining with useDocuments to render a collection of document previews
39+
* @example Combining with useInfiniteList to render a collection of document previews
4040
* ```
4141
* // PreviewComponent.jsx
4242
* export default function PreviewComponent({ document }) {
@@ -51,12 +51,12 @@ export interface UsePreviewResults {
5151
* }
5252
*
5353
* // DocumentList.jsx
54-
* const { data, isPending } = useDocuments({ filter: '_type == "movie"' })
54+
* const { data } = useInfiniteList({ filter: '_type == "movie"' })
5555
* return (
5656
* <div>
5757
* <h1>Movies</h1>
5858
* <ul>
59-
* {isPending ? 'Loading…' : data.map(movie => (
59+
* {data.map(movie => (
6060
* <li key={movie._id}>
6161
* <Suspense fallback='Loading…'>
6262
* <PreviewComponent document={movie} />

packages/react/src/hooks/projects/useProject.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ type UseProject = {
3232
(projectId: string): SanityProject
3333
}
3434

35-
/** @public */
35+
/**
36+
* @public
37+
* @function
38+
*/
3639
export const useProject: UseProject = createStateSourceHook({
3740
// remove `undefined` since we're suspending when that is the case
3841
getState: getProjectState as (

0 commit comments

Comments
 (0)