Skip to content

Commit 134a45f

Browse files
committed
Use JSDoc @import.
1 parent 8b712d4 commit 134a45f

14 files changed

+57
-36
lines changed

public/components/App.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
/** @import { AppComponent } from "ruck/serve.mjs" */
4+
35
import { createElement as h, Fragment, useMemo } from "react";
46
import useCss from "ruck/useCss.mjs";
57
import useHead from "ruck/useHead.mjs";
@@ -12,7 +14,7 @@ const css = new Set([
1214

1315
/**
1416
* React component for the Ruck app.
15-
* @type {import("ruck/serve.mjs").AppComponent}
17+
* @type {AppComponent}
1618
*/
1719
export default function App() {
1820
const route = useRoute();

public/components/Country.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
/** @import { FetchGraphQLResult } from "graphql-react/fetchGraphQL.mjs" */
4+
35
import Loading, { css as cssLoading } from "device-agnostic-ui/Loading.mjs";
46
import Table, { css as cssTable } from "device-agnostic-ui/Table.mjs";
57
import useAutoLoad from "graphql-react/useAutoLoad.mjs";
@@ -47,10 +49,7 @@ const query = /* GraphQL */ `
4749
export default function Country({ countryCode }) {
4850
const cacheKey = `Country-${countryCode}`;
4951
const cacheValue =
50-
/**
51-
* @type {import("graphql-react/fetchGraphQL.mjs").FetchGraphQLResult
52-
* & { data?: QueryData } | undefined}
53-
*/
52+
/** @type {FetchGraphQLResult & { data?: QueryData } | undefined} */
5453
(useCacheEntry(cacheKey));
5554

5655
const loadingCacheValues = useLoadingEntry(cacheKey);

public/components/ErrorMessage.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
/** @import { ReactNode } from "react" */
4+
35
import Heading, { css as cssHeading } from "device-agnostic-ui/Heading.mjs";
46
import { createElement as h } from "react";
57

@@ -12,7 +14,7 @@ export const css = new Set([
1214
* React component for an error message.
1315
* @param {object} props Props.
1416
* @param {string} props.heading Heading.
15-
* @param {import("react").ReactNode} [props.children] Children.
17+
* @param {ReactNode} [props.children] Children.
1618
*/
1719
export default function ErrorMessage({ heading, children }) {
1820
return h(

public/components/ExampleGraphQLError.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
/** @import { FetchGraphQLResult } from "graphql-react/fetchGraphQL.mjs" */
4+
35
import Loading, { css as cssLoading } from "device-agnostic-ui/Loading.mjs";
46
import useAutoLoad from "graphql-react/useAutoLoad.mjs";
57
import useCacheEntry from "graphql-react/useCacheEntry.mjs";
@@ -30,10 +32,7 @@ const query = /* GraphQL */ `
3032
/** React component for example GraphQL errors. */
3133
export default function ExampleGraphQLError() {
3234
const cacheValue =
33-
/**
34-
* @type {import("graphql-react/fetchGraphQL.mjs").FetchGraphQLResult
35-
* & { data?: QueryData } | undefined}
36-
*/
35+
/** @type {FetchGraphQLResult & { data?: QueryData } | undefined} */
3736
(useCacheEntry(cacheKey));
3837
const loadingCacheValues = useLoadingEntry(cacheKey);
3938
const loadCountriesApi = useLoadCountriesApi();

public/components/GithubRepo.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
/** @import { FetchGraphQLResult } from "graphql-react/fetchGraphQL.mjs" */
4+
35
import ButtonSubmit, {
46
css as cssButtonSubmit,
57
} from "device-agnostic-ui/ButtonSubmit.mjs";
@@ -62,10 +64,7 @@ const query = /* GraphQL */ `
6264
export default function GithubRepo({ repoId }) {
6365
const cacheKey = `GithubRepo-${repoId}`;
6466
const cacheValue =
65-
/**
66-
* @type {import("graphql-react/fetchGraphQL.mjs").FetchGraphQLResult
67-
* & { data?: QueryData } | undefined}
68-
*/
67+
/** @type {FetchGraphQLResult & { data?: QueryData } | undefined} */
6968
(useCacheEntry(cacheKey));
7069

7170
const loadingCacheValues = useLoadingEntry(cacheKey);

public/components/GraphQLErrors.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
// @ts-check
22

3+
/**
4+
* @import {
5+
* FetchGraphQLResult,
6+
* FetchGraphQLResultErrorLoading
7+
* } from "graphql-react/fetchGraphQL.mjs"
8+
* @import { GraphQLResultError } from "graphql-react/types.mjs"
9+
* @import { ReactNode } from "react"
10+
*/
11+
312
import ListUnordered, {
413
css as cssListUnordered,
514
} from "device-agnostic-ui/ListUnordered.mjs";
@@ -15,8 +24,8 @@ export const css = new Set([
1524
]);
1625

1726
/**
18-
* @param {import("graphql-react/types.mjs").GraphQLResultError} error
19-
* @returns {error is import("graphql-react/fetchGraphQL.mjs").FetchGraphQLResultErrorLoading}
27+
* @param {GraphQLResultError} error
28+
* @returns {error is FetchGraphQLResultErrorLoading}
2029
*/
2130
function isFetchGraphQLResultErrorLoading(error) {
2231
return typeof error.extensions?.code === "string" && [
@@ -30,9 +39,8 @@ function isFetchGraphQLResultErrorLoading(error) {
3039
/**
3140
* React component for displaying GraphQL errors.
3241
* @param {object} props Props.
33-
* @param {NonNullable<
34-
* import("graphql-react/fetchGraphQL.mjs").FetchGraphQLResult["errors"]
35-
* >} props.errors GraphQL errors.
42+
* @param {NonNullable<FetchGraphQLResult["errors"]>} props.errors GraphQL
43+
* errors.
3644
*/
3745
export default function GraphQLErrors({ errors }) {
3846
return h(
@@ -42,7 +50,7 @@ export default function GraphQLErrors({ errors }) {
4250
/** @type {string} */
4351
let heading;
4452

45-
/** @type {import("react").ReactNode} */
53+
/** @type {ReactNode} */
4654
let children;
4755

4856
if (isFetchGraphQLResultErrorLoading(error)) {

public/components/Header.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
/** @import { ReactNode } from "react" */
4+
35
import { createElement as h } from "react";
46

57
export const css = new Set([
@@ -9,7 +11,7 @@ export const css = new Set([
911
/**
1012
* React component for a header.
1113
* @param {object} props Props.
12-
* @param {import("react").ReactNode} props.children Children.
14+
* @param {ReactNode} props.children Children.
1315
*/
1416
export default function Header({ children }) {
1517
return h("header", { className: "Header__header" }, children);

public/components/PageError.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
/** @import { ReactNode } from "react" */
4+
35
import Heading, { css as cssHeading } from "device-agnostic-ui/Heading.mjs";
46
import Para, { css as cssPara } from "device-agnostic-ui/Para.mjs";
57
import { createElement as h } from "react";
@@ -16,7 +18,7 @@ export const css = new Set([
1618
* React component for a page error.
1719
* @param {object} props Props.
1820
* @param {string} props.title Title.
19-
* @param {import("react").ReactNode} props.description Description.
21+
* @param {ReactNode} props.description Description.
2022
*/
2123
export default function PageError({ title, description }) {
2224
return h(

public/components/SearchGithubRepos.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
/** @import { ComponentPropsWithoutRef } from "react" */
4+
35
import Fieldset, { css as cssFieldset } from "device-agnostic-ui/Fieldset.mjs";
46
import Textbox, { css as cssTextbox } from "device-agnostic-ui/Textbox.mjs";
57
import { createElement as h, useCallback, useState } from "react";
@@ -17,7 +19,7 @@ export default function SearchGithubRepos() {
1719

1820
/**
1921
* @satisfies {NonNullable<
20-
* import("react").ComponentPropsWithoutRef<typeof Textbox>["onChange"]
22+
* ComponentPropsWithoutRef<typeof Textbox>["onChange"]
2123
* >}
2224
*/
2325
const onSearchChange = useCallback(({ target: { value } }) => {

public/components/SearchGithubReposResult.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// @ts-check
22

3+
/** @import { FetchGraphQLResult } from "graphql-react/fetchGraphQL.mjs" */
4+
35
import LinkText, { css as cssLinkText } from "device-agnostic-ui/LinkText.mjs";
46
import ListUnordered, {
57
css as cssListUnordered,
@@ -57,10 +59,7 @@ const query = /* GraphQL */ `
5759
export default function SearchGithubReposResult({ searchQuery }) {
5860
const cacheKey = `SearchGithubReposResult-${searchQuery}`;
5961
const cacheValue =
60-
/**
61-
* @type {import("graphql-react/fetchGraphQL.mjs").FetchGraphQLResult
62-
* & { data?: QueryData } | undefined}
63-
*/
62+
/** @type {FetchGraphQLResult & { data?: QueryData } | undefined} */
6463
(useCacheEntry(cacheKey));
6564

6665
const loadingCacheValues = useLoadingEntry(cacheKey);

0 commit comments

Comments
 (0)