yjs / y-prosemirror

ProseMirror editor binding for Yjs
https://demos.yjs.dev/prosemirror/prosemirror.html
MIT License
335 stars 116 forks source link

TypeScript type error with latest yjs #95

Closed Saul-Mirone closed 2 years ago

Saul-Mirone commented 2 years 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

> 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:

  1. Go to https://github.com/Saul-Mirone/milkdown
  2. Check out the renovate/lock-file-maintenance branch
  3. 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

Additional context Add any other context about the problem here.

dmonad commented 2 years ago

This is likely a typescript issue. Please specify which typescript version are you using.

Saul-Mirone commented 2 years ago

This is likely a typescript issue. Please specify which typescript version are you using.

4.6.2

Saul-Mirone commented 2 years ago

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?

Saul-Mirone commented 2 years ago

A gentle ping @dmonad