Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'rrweb-snapshot' or its corresponding type declarations #252

Open
loremaps opened this issue Jun 24, 2021 · 14 comments · Fixed by #262 or #265
Open

Cannot find module 'rrweb-snapshot' or its corresponding type declarations #252

loremaps opened this issue Jun 24, 2021 · 14 comments · Fixed by #262 or #265
Labels
bug Something isn't working feature/replay

Comments

@loremaps
Copy link

loremaps commented Jun 24, 2021

Hi,

I get the following error when trying to upgrade to a later version than v1.9.7

Error: node_modules/posthog-js/dist/module.d.ts:4:50 - error TS2307: Cannot find module 'rrweb-snapshot' or its corresponding type declarations.

4 import { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'

this is for an Angular 12 project

It looks related to this:

import { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'

Should rrweb-snapshot be added to the dependencies?

FYI it works fine if I install rrweb-snapshot separately.

@Twixes
Copy link
Member

Twixes commented Jul 16, 2021

Does this still happen on the latest version?

@Twixes Twixes added the bug Something isn't working label Jul 16, 2021
@loremaps
Copy link
Author

Yes, it does for version v1.12.1

@novocaine
Copy link

novocaine commented Aug 4, 2021

👋 We are encountering the same issue while validating type definitions using tsc. We aren't currently using rrweb-snapshot or sentry (which types are also being loaded from).

We would prefer not to force our users to install those dependencies which we are not using just to get tsc to validate our project. Might we consider a different approach to re-exporting the types of other libraries in the posthog-js interface? Perhaps we can duplicate the types in posthog's module.d.ts?

novocaine added a commit to matrix-org/matrix-react-sdk that referenced this issue Aug 4, 2021
This is neccessary to resolve re-exported types referred to by posthog-js' type definitions.

This isn't ideal, but

* We intend to start using sentry anyway
* Discussion with posthog maintainers about rrweb-snapshot at PostHog/posthog-js#252, perhaps we can find another solution soon
@Twixes
Copy link
Member

Twixes commented Aug 4, 2021

Hey! We released posthog-js 1.12.3 which should fix this for now by adding rrweb-snapshot to dev-only dependencies. Could you try it out and see if that works better for you?

@loremaps
Copy link
Author

loremaps commented Aug 8, 2021

Hi @Twixes, the issue is still there for me. I created a small repo to reproduce it for your convenience.

So far the only solution that works for me is to install rrweb-snapshot and @sentry/types as devDependencies.

@novocaine
Copy link

Hi @Twixes, the issue is still there for me. I created a small repo to reproduce it for your convenience.

So far the only solution that works for me is to install rrweb-snapshot and @sentry/types as devDependencies.

We have the same problem. Adding the dependencies as dev only dependencies won't help, npm doesn't install the devDependencies of a project's transitive dependencies.

@Twixes
Copy link
Member

Twixes commented Aug 12, 2021

@loremaps A reproducible example is fantastic, thank you!

@novocaine You are of course correct, devDependencies is the wrong lead here. Hence I created #265 that fixes the problem definitively.

@vvolodin
Copy link

I've just added posthog to my Angular 18 project and I'm having this exact issue. What can I do to resolve it?

@loremaps
Copy link
Author

I've just added posthog to my Angular 18 project and I'm having this exact issue. What can I do to resolve it?

Can you try adding "skipLibCheck": true to your tsconfig.json?

@migueldv90
Copy link

I encountered this problem when updating Angular 17 to 18.2.8.

"skipLibCheck": true to your tsconfig.json - worked

also

npm install --save-dev @rrweb/types rrweb-snapshot - worked

Are these the appropriate solutions or stopgaps?

@vvolodin
Copy link

I haven't tried "skipLibCheck" since I really don't want to have it on anyway. I'm sticking to the older version of posthog for now.

@pauldambra
Copy link
Member

reopening this to have somewhere to link people to

@pauldambra pauldambra reopened this Nov 19, 2024
@pauldambra
Copy link
Member

we have rrweb-io/rrweb#1593 open with rrweb... we'd like to fix the root cause here and be able to import the types and not the packages so that our dependencies are clear

@siimveskilt
Copy link

siimveskilt commented Jan 6, 2025

Looks like it has been merged and released on rrweb side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature/replay
Projects
None yet
9 participants