🏷️(frontend) adapt types to typescript v6

We updated typescript to v6, which includes some
breaking changes. This commit adapts our code to
be compatible with the new version of typescript.
This commit is contained in:
Anthony LC
2026-05-05 10:53:38 +02:00
parent 9231730bf0
commit 0e8094c733
19 changed files with 43 additions and 45 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es2020",
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
@@ -1,12 +1,13 @@
import { Ref, forwardRef } from 'react'; import { ComponentPropsWithRef, Ref, forwardRef } from 'react';
import { css } from 'styled-components'; import { css } from 'styled-components';
import { Box, BoxType } from './Box'; import { Box, BoxProps } from './Box';
export type BoxButtonType = Omit<BoxType, 'ref'> & { export type BoxButtonType = BoxProps &
disabled?: boolean; Omit<ComponentPropsWithRef<'button'>, keyof BoxProps | 'ref'> & {
ref?: Ref<HTMLButtonElement>; disabled?: boolean;
}; ref?: Ref<HTMLButtonElement>;
};
/** /**
* Styleless button that extends the Box component. * Styleless button that extends the Box component.
@@ -59,7 +60,7 @@ const BoxButton = forwardRef<HTMLButtonElement, BoxButtonType>(
if (disabled) { if (disabled) {
return; return;
} }
props.onClick?.(event as unknown as React.MouseEvent<HTMLDivElement>); props.onClick?.(event);
}} }}
/> />
); );
@@ -34,9 +34,7 @@ export const TextStyled = styled(Box)<TextProps>`
const Text = forwardRef<HTMLElement, ComponentPropsWithRef<typeof TextStyled>>( const Text = forwardRef<HTMLElement, ComponentPropsWithRef<typeof TextStyled>>(
(props, ref) => { (props, ref) => {
return ( return <TextStyled ref={ref} as="span" {...props} />;
<TextStyled ref={ref as React.Ref<HTMLDivElement>} as="span" {...props} />
);
}, },
); );
@@ -35,7 +35,7 @@ const initialState: ThemeStore = {
colorsTokens: defaultTokens.globals.colors, colorsTokens: defaultTokens.globals.colors,
componentTokens: defaultTokens.components, componentTokens: defaultTokens.components,
contextualTokens: defaultTokens.contextuals, contextualTokens: defaultTokens.contextuals,
currentTokens: tokens.themes[DEFAULT_THEME] as Partial<Tokens>, currentTokens: tokens.themes[DEFAULT_THEME],
fontSizesTokens: defaultTokens.globals.font.sizes, fontSizesTokens: defaultTokens.globals.font.sizes,
setTheme: () => {}, setTheme: () => {},
spacingsTokens: defaultTokens.globals.spacings, spacingsTokens: defaultTokens.globals.spacings,
@@ -1,12 +1,13 @@
import React from 'react'; import React, { ComponentPropsWithRef } from 'react';
import { Box, BoxType } from '@/components'; import { Box, BoxProps } from '@/components';
type AvatarSvgProps = { type AvatarSvgProps = BoxProps &
initials: string; Omit<ComponentPropsWithRef<'svg'>, keyof BoxProps> & {
background: string; initials: string;
fontFamily?: string; background: string;
} & BoxType; fontFamily?: string;
};
export const AvatarSvg: React.FC<AvatarSvgProps> = ({ export const AvatarSvg: React.FC<AvatarSvgProps> = ({
initials, initials,
@@ -67,7 +67,7 @@ export class DocsThreadStore extends ThreadStore {
continue; continue;
} }
const state = states.get(clientId) as const state:
| { | {
[DocsThreadStore.COMMENTS_PING]?: { [DocsThreadStore.COMMENTS_PING]?: {
at: number; at: number;
@@ -76,7 +76,7 @@ export class DocsThreadStore extends ThreadStore {
threadId: string; threadId: string;
}; };
} }
| undefined; | undefined = states.get(clientId);
const ping = state?.commentsPing; const ping = state?.commentsPing;
@@ -41,7 +41,7 @@ export const LinkSelected = ({
const router = useRouter(); const router = useRouter();
const href = `/docs/${docId}/`; const href = `/docs/${docId}/`;
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => { const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault(); e.preventDefault();
// If ctrl or command is pressed, it opens a new tab. If shift is pressed, it opens a new window // If ctrl or command is pressed, it opens a new tab. If shift is pressed, it opens a new window
@@ -53,7 +53,7 @@ export const LinkSelected = ({
}; };
// This triggers on middle-mouse click // This triggers on middle-mouse click
const handleAuxClick = (e: React.MouseEvent<HTMLDivElement>) => { const handleAuxClick = (e: React.MouseEvent<HTMLButtonElement>) => {
if (e.button !== 1) { if (e.button !== 1) {
return; return;
} }
@@ -39,7 +39,13 @@ const withMultiColumnNoDropHandler = <
}); });
}; };
let modulesXL = undefined; type ModulesXL =
| (Omit<typeof XLMultiColumn, 'withMultiColumn'> & {
withMultiColumn: typeof withMultiColumnNoDropHandler;
})
| undefined;
let modulesXL: ModulesXL = undefined;
if (process.env.NEXT_PUBLIC_PUBLISH_AS_MIT === 'false') { if (process.env.NEXT_PUBLIC_PUBLISH_AS_MIT === 'false') {
modulesXL = { modulesXL = {
...XLMultiColumn, ...XLMultiColumn,
@@ -47,10 +53,4 @@ if (process.env.NEXT_PUBLIC_PUBLISH_AS_MIT === 'false') {
}; };
} }
type ModulesXL = export default modulesXL;
| (Omit<typeof XLMultiColumn, 'withMultiColumn'> & {
withMultiColumn: typeof withMultiColumnNoDropHandler;
})
| undefined;
export default modulesXL as ModulesXL;
@@ -11,7 +11,7 @@ import {
useToastProvider, useToastProvider,
} from '@gouvfr-lasuite/cunningham-react'; } from '@gouvfr-lasuite/cunningham-react';
import { DocumentProps, pdf } from '@react-pdf/renderer'; import { DocumentProps, pdf } from '@react-pdf/renderer';
import jsonemoji from 'emoji-datasource-apple' assert { type: 'json' }; import jsonemoji from 'emoji-datasource-apple' with { type: 'json' };
import i18next from 'i18next'; import i18next from 'i18next';
import JSZip from 'jszip'; import JSZip from 'jszip';
import { cloneElement, isValidElement, useState } from 'react'; import { cloneElement, isValidElement, useState } from 'react';
@@ -16,6 +16,4 @@ if (process.env.NEXT_PUBLIC_PUBLISH_AS_MIT === 'false') {
}; };
} }
type ModulesExport = typeof modulesExport; export default modulesExport;
export default modulesExport as ModulesExport;
@@ -68,7 +68,7 @@ export const BoutonShare = ({
/> />
} }
onClick={(e) => { onClick={(e) => {
addLastFocus(e.currentTarget as HTMLElement); addLastFocus(e.currentTarget);
open(); open();
}} }}
size="medium" size="medium"
@@ -85,7 +85,7 @@ export const BoutonShare = ({
color="brand" color="brand"
variant="tertiary" variant="tertiary"
onClick={(e) => { onClick={(e) => {
addLastFocus(e.currentTarget as HTMLElement); addLastFocus(e.currentTarget);
open(); open();
}} }}
size="medium" size="medium"
@@ -244,7 +244,7 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => {
<Icon iconName="download" $color="inherit" aria-hidden={true} /> <Icon iconName="download" $color="inherit" aria-hidden={true} />
} }
onClick={(e) => { onClick={(e) => {
addLastFocus(e.currentTarget as HTMLElement); addLastFocus(e.currentTarget);
setIsModalExportOpen(true); setIsModalExportOpen(true);
}} }}
size={isSmallMobile ? 'small' : 'medium'} size={isSmallMobile ? 'small' : 'medium'}
@@ -50,7 +50,7 @@ export const DocsGridItemSharedButton = ({ doc, disabled }: Props) => {
onClick={(event) => { onClick={(event) => {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
addLastFocus(event.currentTarget as HTMLElement); addLastFocus(event.currentTarget);
shareModal.open(); shareModal.open();
}} }}
color="brand" color="brand"
@@ -50,7 +50,7 @@ export class RequestSerializer {
public static arrayBufferToString(buffer: ArrayBufferLike) { public static arrayBufferToString(buffer: ArrayBufferLike) {
const decoder = new TextDecoder(); const decoder = new TextDecoder();
return decoder.decode(buffer as ArrayBuffer); return decoder.decode(buffer);
} }
public static arrayBufferToJson<T>(buffer: ArrayBufferLike) { public static arrayBufferToJson<T>(buffer: ArrayBufferLike) {
@@ -15,7 +15,7 @@ const mockServiceWorkerScope = {
(global as any).self = { (global as any).self = {
...global, ...global,
clients: mockServiceWorkerScope.clients, clients: mockServiceWorkerScope.clients,
} as unknown as ServiceWorkerGlobalScope; };
describe('OfflinePlugin', () => { describe('OfflinePlugin', () => {
afterEach(() => vi.clearAllMocks()); afterEach(() => vi.clearAllMocks());
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es2020",
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es2020",
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
@@ -62,7 +62,7 @@ const readers: InputReader[] = [
const ydoc = new Y.Doc(); const ydoc = new Y.Doc();
try { try {
Y.applyUpdate(ydoc, data); Y.applyUpdate(ydoc, data);
return editor.yDocToBlocks(ydoc, 'document-store') as PartialBlock[]; return editor.yDocToBlocks(ydoc, 'document-store');
} finally { } finally {
ydoc.destroy(); ydoc.destroy();
} }
@@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es2020",
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,