yjs / y-websocket

Websocket Connector for Yjs
https://docs.yjs.dev/ecosystem/connection-provider/y-websocket
MIT License
526 stars 263 forks source link

Could not find a declaration file for module 'y-websocket' #155

Open sa- opened 1 year ago

sa- commented 1 year ago

Please save me some time and use the following template. In 90% of all issues I can't reproduce the problem because I don't know what exactly you are doing, in which environment, or which y-* version is responsible. Just use the following template even if you think the problem is obvious.

Checklist

Describe the bug When importing y-websocket import { WebsocketProvider } from 'y-websocket', I get the error

Could not find a declaration file for module 'y-websocket'. '/Users/sa/.../node_modules/y-websocket/src/y-websocket.js' implicitly has an 'any' type.
  There are types at '/Users/sa/.../node_modules/y-websocket/dist/src/y-websocket.d.ts', but this result could not be resolved when respecting package.json "exports". The 'y-websocket' library may need to update its package.json or typings.

I am getting around it by adding a // @ts-ignore before the import statement.

To Reproduce Steps to reproduce the behavior:

  1. Create a new Vite project with typescript, with vanilla js
  2. Install these dependencies by editing your package.json file
    ...
    "devDependencies": {
    "typescript": "^5.0.2",
    "vite": "^4.4.5"
    },
    "dependencies": {
    "monaco-editor": "^0.43.0",
    "y-monaco": "^0.1.4",
    "y-websocket": "^1.5.0"
    }
    ...
  3. Put import { WebsocketProvider } from 'y-websocket' in main.ts

Expected behavior It correctly uses the types file at y-websocket/dist/src/y-websocket.d.ts

Screenshots

image

Environment Information

Additional context Add any other context about the problem here.

sa- commented 1 year ago

This is my first bug report here, and I would just like to thank you for building this awesome lib!

giraugh commented 1 year ago

Looks like this is fixed by #138 which has been approved just not merged.

landonturner commented 1 year ago

It was merged in a separate pr. #138 should probably be closed.

relevant line in package.json for the types: https://github.com/yjs/y-websocket/blob/master/package.json#L37

@dmonad any plans on doing a release soon that includes this fix?