Why does Visual Studio Code throw error "Could not find a declaration file for module" when using chatkit-client-js?

When working with the Chatkit libraries in VSC you may come accross the following error

Could not find a declaration file for module '@pusher/chatkit-client'. '/usr/node_modules/@pusher/chatkit-client/dist/web/chatkit.js' implicitly has an 'any' type.
Try `npm install @types/pusher__chatkit-client` if it exists or add a new declaration (.d.ts) file containing `declare module '@pusher/chatkit-client';`" ts(7016)

This error should not prevent your code from running. However, to prevent the error from being displayed you can simply create a 'chatkit.d.ts' file at the same level as your 'Chatscreen.js' file with the contents
declare module '@pusher/chatkit-client';

This should allow VSC to overlook the lack of typing and instead import the module with the any typing.

Was this article helpful?
0 out of 0 found this helpful
Haven't found what you were looking for?
Submit a ticket