Skip to content

Commit cc17baa

Browse files
committed
Don't be to restrictive on the type of the Link component passed by dsfr start, it provide no added safety #247
1 parent e6103d6 commit cc17baa

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

src/next-appdir/DsfrHead.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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, type RegisterLink } from "../link";
10+
import { setLink } 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?: RegisterLink extends { Link: infer Link } ? Link : undefined;
25+
Link?: Function;
2626
/**
2727
* When set, the value will be used as the nonce attribute of subsequent script tags.
2828
*
@@ -68,7 +68,7 @@ export function DsfrHead(props: DsfrHeadProps) {
6868

6969
useMemo(() => {
7070
if (Link !== undefined) {
71-
setLink({ Link });
71+
setLink({ "Link": Link as any });
7272
}
7373
}, [Link]);
7474

src/next-appdir/zz_internal/start.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { start } from "../../start";
2-
import type { RegisterLink } from "../../link";
32
import { setLink } from "../../link";
43
import { type DefaultColorScheme, setDefaultColorSchemeClientSide } from "./defaultColorScheme";
54
import { isBrowser } from "../../tools/isBrowser";
@@ -14,7 +13,7 @@ export function startReactDsfr(params: {
1413
/** Default: false */
1514
verbose?: boolean;
1615
/** Default: <a /> */
17-
Link?: RegisterLink extends { Link: infer Link } ? Link : undefined;
16+
Link?: Function;
1817
/**
1918
* When true, the nonce of the script tag will be checked, fetched from {@link DsfrHead} component and injected in react-dsfr scripts.
2019
*
@@ -54,7 +53,7 @@ export function startReactDsfr(params: {
5453
setDefaultColorSchemeClientSide({ defaultColorScheme });
5554

5655
if (Link !== undefined) {
57-
setLink({ Link });
56+
setLink({ "Link": Link as any });
5857
}
5958

6059
if (isBrowser) {

src/next-pagesdir.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type CreateNextDsfrIntegrationApiParams = {
3232
/** Default: false */
3333
verbose?: boolean;
3434
/** Default: <a /> */
35-
Link?: RegisterLink extends { Link: infer Link } ? Link : undefined;
35+
Link?: Function;
3636
/** If not provided no fonts are preloaded.
3737
* Preloading of fonts is only enabled in production.
3838
*/
@@ -121,7 +121,7 @@ export function createNextDsfrIntegrationApi(
121121
const actions: (() => void)[] = [];
122122

123123
if (Link !== undefined) {
124-
setLink({ Link });
124+
setLink({ "Link": Link as any });
125125
}
126126

127127
if (useLang !== undefined) {

src/spa.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function startReactDsfr(params: {
1212
/** Default: false */
1313
verbose?: boolean;
1414
/** Default: <a /> */
15-
Link?: RegisterLink extends { Link: infer Link } ? Link : undefined;
15+
Link?: Function;
1616
/** Default: ()=> "fr" */
1717
useLang?: () => string;
1818
/**
@@ -50,7 +50,7 @@ export function startReactDsfr(params: {
5050
} = params;
5151

5252
if (Link !== undefined) {
53-
setLink({ Link });
53+
setLink({ "Link": Link as any });
5454
}
5555

5656
if (useLang !== undefined) {

0 commit comments

Comments
 (0)