Our project uses type: module in its package.json, and module: nodenext in its tsconfig (the default in tsc --init) and we encountered a type error while trying to access Session Replay API.
Reproduction:
mkdir mixpanel-type-issue
cd mixpanel-type-issue
npm init -y
npm pkg set type=module
npm i mixpanel-browser typescript
npx tsc --init
echo "import mixpanel from 'mixpanel-browser'; mixpanel.start_session_recording();" > main.ts
npx tsc --noEmit
results in
main.ts:1:51 - error TS2339: Property 'start_session_recording' does not exist on type 'typeof import("node_modules/mixpanel-browser/src/index")'.
1 import mixpanel from 'mixpanel-browser'; mixpanel.start_session_recording();
~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in main.ts:1
If I write mixpanel.default.start_session_recording() typecheck passes. so it has to do with the hybrid mixpanel package (cjs+esm) being imported by our native esm package in this mode.
We try to integrate this in a react-router v7 project that combines both node and browser code.
Our project uses
type: modulein itspackage.json, andmodule: nodenextin its tsconfig (the default intsc --init) and we encountered a type error while trying to access Session Replay API.Reproduction:
results in
If I write
mixpanel.default.start_session_recording()typecheck passes. so it has to do with the hybrid mixpanel package (cjs+esm) being imported by our native esm package in this mode.We try to integrate this in a react-router v7 project that combines both node and browser code.