Skip to content

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

@sa-

Description

@sa-

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions