Skip to content

Commit f95274d

Browse files
committed
#204: Follow up
1 parent 168aa63 commit f95274d

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

src/next-appdir/DsfrHead.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useMemo, type ReactNode } from "react";
1+
import React, { useMemo } from "react";
22
import { objectKeys } from "tsafe/objectKeys";
33
import { getAssetUrl } from "../tools/getAssetUrl";
44
import AppleTouchIcon from "../dsfr/favicon/apple-touch-icon.png";
@@ -7,7 +7,7 @@ import FaviconIco from "../dsfr/favicon/favicon.ico";
77
import { getScriptToRunAsap } from "../useIsDark/scriptToRunAsap";
88
import { fontUrlByFileBasename } from "./zz_internal/fontUrlByFileBasename";
99
import { getDefaultColorSchemeServerSide } from "./zz_internal/defaultColorScheme";
10-
import { setLink, RegisteredLinkProps } from "../link";
10+
import { setLink, type RegisterLink } from "../link";
1111
import { assert } from "tsafe/assert";
1212
//NOTE: As of now there is no way to enforce ordering in Next Appdir
1313
//See: https://github.com/vercel/next.js/issues/16630
@@ -22,7 +22,7 @@ export type DsfrHeadProps = {
2222
*/
2323
preloadFonts?: (keyof typeof fontUrlByFileBasename)[];
2424
/** Default: <a /> */
25-
Link?: React.ComponentType<RegisteredLinkProps & { children: ReactNode }>;
25+
Link?: RegisterLink extends { Link: infer Link } ? Link : undefined;
2626
/**
2727
* When set, the value will be used as the nonce attribute of subsequent script tags.
2828
*

src/next-appdir/zz_internal/start.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { ReactNode } from "react";
21
import { start } from "../../start";
3-
import type { RegisteredLinkProps } from "../../link";
2+
import type { RegisterLink } from "../../link";
43
import { setLink } from "../../link";
54
import { type DefaultColorScheme, setDefaultColorSchemeClientSide } from "./defaultColorScheme";
65
import { isBrowser } from "../../tools/isBrowser";
@@ -15,7 +14,7 @@ export function startReactDsfr(params: {
1514
/** Default: false */
1615
verbose?: boolean;
1716
/** Default: <a /> */
18-
Link?: React.ComponentType<RegisteredLinkProps & { children: ReactNode }>;
17+
Link?: RegisterLink extends { Link: infer Link } ? Link : undefined;
1918
/**
2019
* When true, the nonce of the script tag will be checked, fetched from {@link DsfrHead} component and injected in react-dsfr scripts.
2120
*

src/next-pagesdir.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, type ReactNode } from "react";
1+
import React, { useEffect } from "react";
22
import Head from "next/head";
33
import type { NextComponentType } from "next";
44
import DefaultApp from "next/app";
@@ -32,7 +32,7 @@ export type CreateNextDsfrIntegrationApiParams = {
3232
/** Default: false */
3333
verbose?: boolean;
3434
/** Default: <a /> */
35-
Link?: React.ComponentType<RegisteredLinkProps & { children: ReactNode }>;
35+
Link?: RegisterLink extends { Link: infer Link } ? Link : undefined;
3636
/** If not provided no fonts are preloaded.
3737
* Preloading of fonts is only enabled in production.
3838
*/

src/spa.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { ReactNode } from "react";
21
import { start } from "./start";
32
import type { RegisterLink, RegisteredLinkProps } from "./link";
43
import { setLink } from "./link";
@@ -13,7 +12,7 @@ export function startReactDsfr(params: {
1312
/** Default: false */
1413
verbose?: boolean;
1514
/** Default: <a /> */
16-
Link?: React.ComponentType<RegisteredLinkProps & { children: ReactNode }>;
15+
Link?: RegisterLink extends { Link: infer Link } ? Link : undefined;
1716
/** Default: ()=> "fr" */
1817
useLang?: () => string;
1918
/**

0 commit comments

Comments
 (0)