Closed
Description
Mostly filing this for others to discover if they run into the same issue. I understand that you probably won't make a change to the typings to address this issue, but it would be nice to update the v8.x migration guide to mention this additional breaking change.
Bug description
When upgrading to react-day-picker v8.x in a TypeScript project, I encountered this compilation error:
node_modules/.pnpm/react-day-picker@8.8.2_67dtbe47ihz5epdhb3oajtg74u/node_modules/react-day-picker/dist/index.d.ts:2:8 - error TS1259: Module '"/home/circleci/project/node_modules/.pnpm/@types+react@16.14.32/node_modules/@types/react/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
2 import React$1, { ReactNode, HTMLProps } from 'react';
~~~~~~~
node_modules/.pnpm/@types+react@16.14.32/node_modules/@types/react/index.d.ts:61:1
61 export = React;
~~~~~~~~~~~~~~~
This module is declared with 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
Note that I am currently using @types/react v16.x, but the same issue would apply to the latest v18.x types.
To reproduce
https://codesandbox.io/p/sandbox/react-daypicker-forked-vcg8w5?file=%2Ftsconfig.json%3A8%2C21
Need these tsconfig options:
{
"compilerOptions": {
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": false,
"isolatedModules": false
}
}
Expected behavior
Either:
- react-day-picker v8 works without
allowSyntheticDefaultImports: true
, OR - the migration guide mentions this as a TypeScript breaking change.