y-websocket icon indicating copy to clipboard operation
y-websocket copied to clipboard

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

Open sa- opened this issue 1 year ago • 3 comments

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

  • [x] Are you reporting a bug? Use github issues for bug reports and feature requests. For general questions, please use https://discuss.yjs.dev/
  • [x] Try to report your issue in the correct repository. Yjs consists of many modules. When in doubt, report it to https://github.com/yjs/yjs/issues/

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"
  }
...
  1. 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

  • MacOS M1
  • Yjs version 13.6.8
  • y-websocket 1.5.0
  • y-monaco 0.1.4
  • monaco-editor 0.43.0

Additional context Add any other context about the problem here.

sa- avatar Sep 23 '23 06:09 sa-

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

sa- avatar Sep 23 '23 06:09 sa-

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

giraugh avatar Oct 26 '23 04:10 giraugh

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?

landonturner avatar Oct 27 '23 16:10 landonturner