TypeScript type error with latest yjs
Saul-Mirone opened this issue · 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
- Are you reporting a bug? Use github issues for bug reports and feature requests. For general questions, please use https://discuss.yjs.dev/
- 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
> tsc --noEmit
../../node_modules/.pnpm/y-prosemirror@1.0.15_y-protocols@1.0.5+yjs@13.5.28/node_modules/y-prosemirror/dist/src/plugins/sync-plugin.d.ts:55:32 - error TS2314: Generic type 'YEvent<T>' requires 1 type argument(s).
55 _typeChanged(events: Array<Y.YEvent>, transaction: Y.Transaction): void;
~~~~~~~~
Found 1 error in ../../node_modules/.pnpm/y-prosemirror@1.0.15_y-protocols@1.0.5+yjs@13.5.28/node_modules/y-prosemirror/dist/src/plugins/sync-plugin.d.ts:55
To Reproduce
Steps to reproduce the behavior:
- Go to https://github.com/Saul-Mirone/milkdown
- Check out the
renovate/lock-file-maintenance
branch - Run
pnpm install && pnpm build:packs
Expected behavior
A clear and concise description of what you expected to happen.
Typesciript can compile with no error.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment Information
- Browser / Node.js [e.g. Chrome, Firefox, Node.js]
- Yjs@13.5.28, y-prosemirror@1.0.15
Additional context
Add any other context about the problem here.
This is likely a typescript issue. Please specify which typescript version are you using.
This is likely a typescript issue. Please specify which typescript version are you using.
4.6.2
After a little investigation. I think it's not a typescript issue.
You define the YEvent as a generic class here: https://github.com/yjs/yjs/blob/main/src/utils/YEvent.js#L11
If you want to give it a default value, I think you can use:
/**
* @template {AbstractType<any>} [T = AbstractType<any>]
* YEvent describes the changes on a YType.
*/
Do you want me to put out a PR for this?