diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 4826362b..d912934e 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -1,6 +1,7 @@ import { SCWUITheme, normalize, theme } from '@scaleway/ui' import { css, ThemeProvider, Global, Theme } from '@emotion/react' +import { Story } from '@storybook/react' const STORY_SORT = { order: [ @@ -46,17 +47,24 @@ const ENV_PARAMETERS = { }, } export const parameters = - ENV_PARAMETERS[process.env.STORYBOOK_ENVIRONMENT] || ENV_PARAMETERS.production + (process.env?.['STORYBOOK_ENVIRONMENT'] as keyof typeof ENV_PARAMETERS) || + ENV_PARAMETERS.production -const adjustedTheme = ancestorTheme => +const adjustedTheme = (ancestorTheme: Theme) => ({ ...ancestorTheme, ...Object.keys(theme).reduce( (acc, themeItem) => ({ ...acc, [themeItem]: { - ...(acc[themeItem] ?? {}), - ...theme[themeItem], + ...((acc[themeItem as keyof typeof theme] as Record< + string, + unknown + >) ?? {}), + ...(theme[themeItem as keyof typeof theme] as Record< + string, + unknown + >), }, }), ancestorTheme, @@ -68,10 +76,10 @@ export const globalStyles = (_: Theme) => css` ` export const decorators = [ - Story => ( + (StoryComponent: Story) => ( - + ), ] diff --git a/.storybook/scaleway.ts b/.storybook/scaleway.ts index a6c776e2..b0773424 100644 --- a/.storybook/scaleway.ts +++ b/.storybook/scaleway.ts @@ -1,4 +1,4 @@ -import { create } from '@storybook/theming/create' +import { create } from '@storybook/theming' import brandImage from './assets/scaleway-text.png' export default create({ diff --git a/package.json b/package.json index 229da5d7..dea9324c 100644 --- a/package.json +++ b/package.json @@ -140,6 +140,7 @@ "@rollup/plugin-url": "8.0.1", "@scaleway/eslint-config-react": "3.11.0", "@scaleway/jest-helpers": "2.0.24", + "@scaleway/tsconfig": "^1.1.0", "@semantic-release/changelog": "6.0.2", "@semantic-release/commit-analyzer": "9.0.2", "@semantic-release/git": "10.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b0e5c53c..7136ea4a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,7 @@ specifiers: '@rollup/plugin-url': 8.0.1 '@scaleway/eslint-config-react': 3.11.0 '@scaleway/jest-helpers': 2.0.24 + '@scaleway/tsconfig': ^1.1.0 '@scaleway/ui': 0.213.3 '@semantic-release/changelog': 6.0.2 '@semantic-release/commit-analyzer': 9.0.2 @@ -111,6 +112,7 @@ devDependencies: '@rollup/plugin-url': 8.0.1_rollup@3.5.1 '@scaleway/eslint-config-react': 3.11.0_hsf322ms6xhhd4b5ne6lb74y4a '@scaleway/jest-helpers': 2.0.24_34ch25xmpqfrx6wylcxtcsskau + '@scaleway/tsconfig': 1.1.0 '@semantic-release/changelog': 6.0.2_semantic-release@19.0.5 '@semantic-release/commit-analyzer': 9.0.2_semantic-release@19.0.5 '@semantic-release/git': 10.0.1_semantic-release@19.0.5 @@ -3083,6 +3085,10 @@ packages: resolution: {integrity: sha512-vEL2RegTjZx/3ZEgVgWvNfxsXUZZ0ieiheNva+mXbHCrWc6f0CvntMezf8dONVajLC4Wi6V7Fo2Y9lhnJbvNow==} dev: false + /@scaleway/tsconfig/1.1.0: + resolution: {integrity: sha512-dZyeub6snbFUD0oTTgiUsdHYYOcyZDbQ5lSgAaZBCVS6FxF2R2HiLVwtrD6pw9IebhyPne2z8M4BsZQ4Rg+K1w==} + dev: true + /@scaleway/ui/0.213.3_mhi3dw3nus7rwpybrnmmfhzmsa: resolution: {integrity: sha512-qiBzFM+rzjkKtoYE8xtDFHPHFtctSJW0Qs5BW6Zusut8ZaKR38HqQ0N2yqwYvrZNrOSCyWPOxCuwbF7ThK+zSw==} engines: {node: '>=18.x', pnpm: '>=7.0.0'} diff --git a/src/components/DateField/__tests__/index.tsx b/src/components/DateField/__tests__/index.tsx index 7bdf5e45..9b5c732c 100644 --- a/src/components/DateField/__tests__/index.tsx +++ b/src/components/DateField/__tests__/index.tsx @@ -37,7 +37,7 @@ describe('DateField', () => { }) const option = node.getAllByRole('option')[0] await act(() => { - option.click() + option?.click() }) expect(onChange).toBeCalledTimes(1) // Blur not working on react-datepicker: diff --git a/src/mocks/mockErrors.ts b/src/mocks/mockErrors.ts index 0942ba87..baa21f7e 100644 --- a/src/mocks/mockErrors.ts +++ b/src/mocks/mockErrors.ts @@ -11,8 +11,9 @@ export const mockErrors: FormErrors = { `This field should have a length greater than ${minLength}`, REGEX: ({ regex }) => { if ( - (Array.isArray(regex[0]) ? regex[0][0].source : regex[0].source) === - emailRegex.source + (Array.isArray(regex[0]) + ? regex?.[0]?.[0]?.source + : regex?.[0]?.source) === emailRegex.source ) { return 'Invalid email' } diff --git a/tsconfig.json b/tsconfig.json index 01aa6cb3..a273b08d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,26 +1,19 @@ { + "extends": "@scaleway/tsconfig", "compilerOptions": { - "target": "es2020", - "module": "esnext", - "strict": true, - "allowSyntheticDefaultImports": true, - "allowJs": true, - "esModuleInterop": true, + "target": "esnext", + // For storybook compatibility we use commonjs + "module": "commonjs", + "jsxImportSource": "@emotion/react", + "noEmit": true, - "moduleResolution": "node", "skipLibCheck": true, - "jsx": "preserve" }, "include": [ - "./storybook/**/*.ts", - "./storybook/**/*.tsx", "**/*.ts", "**/*.tsx", - "emotion.d.ts", + ".storybook/**/*.ts", + ".storybook/**/*.tsx" ], - "exclude": [ - "node_modules", - "coverage", - "dist" - ] + "exclude": ["node_modules", "coverage", "dist"] }