Skip to content

Type error when trying to acess "start_session_recording" with native esm + default tsconfig #583

Description

@PeterShershov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions