From 9aa8a572ad1f34bcf9624d15f73d626687d3642d Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Tue, 31 Oct 2023 20:39:48 +0100 Subject: [PATCH] #204: Follow up --- src/link.tsx | 8 ++------ src/next-appdir/DsfrHead.tsx | 4 ++-- src/next-appdir/zz_internal/start.ts | 2 +- src/next-pagesdir.tsx | 2 +- src/spa.ts | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/link.tsx b/src/link.tsx index dc52da25..ff7599a7 100644 --- a/src/link.tsx +++ b/src/link.tsx @@ -11,15 +11,13 @@ type HTMLAnchorProps = DetailedHTMLProps< >; // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface RegisterLink {} +export interface RegisterLink { } export type RegisteredLinkProps = RegisterLink extends { Link: infer Link } ? Omit, "children"> : Omit; -let Link: ( - props: RegisteredLinkProps & { children: ReactNode } -) => ReturnType = props => { +let Link: React.ComponentType = props => { const { href, ...rest } = props as { to?: string; href?: string }; button: { @@ -42,8 +40,6 @@ let Link: ( return ; }; -//; - export function setLink(params: { Link: typeof Link }): void { Link = props => { { diff --git a/src/next-appdir/DsfrHead.tsx b/src/next-appdir/DsfrHead.tsx index bed5e646..b7065b39 100644 --- a/src/next-appdir/DsfrHead.tsx +++ b/src/next-appdir/DsfrHead.tsx @@ -7,7 +7,7 @@ import FaviconIco from "../dsfr/favicon/favicon.ico"; import { getScriptToRunAsap } from "../useIsDark/scriptToRunAsap"; import { fontUrlByFileBasename } from "./zz_internal/fontUrlByFileBasename"; import { getDefaultColorSchemeServerSide } from "./zz_internal/defaultColorScheme"; -import { setLink, type RegisteredLinkProps } from "../link"; +import { setLink, RegisteredLinkProps } from "../link"; import { assert } from "tsafe/assert"; //NOTE: As of now there is no way to enforce ordering in Next Appdir //See: https://github.com/vercel/next.js/issues/16630 @@ -22,7 +22,7 @@ export type DsfrHeadProps = { */ preloadFonts?: (keyof typeof fontUrlByFileBasename)[]; /** Default: */ - Link?: (props: RegisteredLinkProps & { children: ReactNode }) => ReturnType; + Link?: React.ComponentType; /** * When set, the value will be used as the nonce attribute of subsequent script tags. * diff --git a/src/next-appdir/zz_internal/start.ts b/src/next-appdir/zz_internal/start.ts index dce44028..3522dd9e 100644 --- a/src/next-appdir/zz_internal/start.ts +++ b/src/next-appdir/zz_internal/start.ts @@ -15,7 +15,7 @@ export function startReactDsfr(params: { /** Default: false */ verbose?: boolean; /** Default: */ - Link?: (props: RegisteredLinkProps & { children: ReactNode }) => ReturnType; + Link?: React.ComponentType; /** * When true, the nonce of the script tag will be checked, fetched from {@link DsfrHead} component and injected in react-dsfr scripts. * diff --git a/src/next-pagesdir.tsx b/src/next-pagesdir.tsx index 4290e7d0..dd86c556 100644 --- a/src/next-pagesdir.tsx +++ b/src/next-pagesdir.tsx @@ -32,7 +32,7 @@ export type CreateNextDsfrIntegrationApiParams = { /** Default: false */ verbose?: boolean; /** Default: */ - Link?: (props: RegisteredLinkProps & { children: ReactNode }) => ReturnType; + Link?: React.ComponentType; /** If not provided no fonts are preloaded. * Preloading of fonts is only enabled in production. */ diff --git a/src/spa.ts b/src/spa.ts index 629f9edc..b994c957 100644 --- a/src/spa.ts +++ b/src/spa.ts @@ -13,7 +13,7 @@ export function startReactDsfr(params: { /** Default: false */ verbose?: boolean; /** Default: */ - Link?: (props: RegisteredLinkProps & { children: ReactNode }) => ReturnType; + Link?: React.ComponentType; /** Default: ()=> "fr" */ useLang?: () => string; /**