kilbd / nova-rust

A Rust extension for the Nova text editor, using the Rust Analyzer language server.
MIT License
29 stars 5 forks source link

[BUG] Unable to build dependencies because of type mismatch #45

Open edwardloveall opened 1 year ago

edwardloveall commented 1 year ago

Describe the bug

Hello!

The readme says to build the extension with npm run build. When I do that on the current main branch, I get a bunch of type errors. Some are missing from @types/nova-editor-node that I addressed in #44 but one ('LanguageClient' is not assignable to parameter of type 'Disposable') is not.

To Reproduce Steps to reproduce the behavior:

  1. Follow the readme and run npm build
  2. See the following errors:
src/rust-lang-server.ts:66:33 - error TS2345: Argument of type 'LanguageClient' is not assignable to parameter of type 'Disposable'.
  Property 'dispose' is missing in type 'LanguageClient' but required in type 'Disposable'.

66       nova.subscriptions.remove(this.languageClient)
                                   ~~~~~~~~~~~~~~~~~~~

  node_modules/@types/nova-editor-node/index.d.ts:341:5
    341     dispose(): void;
            ~~~~~~~
    'dispose' is declared here.

src/rust-lang-server.ts:76:33 - error TS2345: Argument of type 'LanguageClient' is not assignable to parameter of type 'Disposable'.

76       nova.subscriptions.remove(this.languageClient)
                                   ~~~~~~~~~~~~~~~~~~~

src/rust-lang-server.ts:146:30 - error TS2345: Argument of type 'LanguageClient' is not assignable to parameter of type 'Disposable'.

146       nova.subscriptions.add(client)
                                 ~~~~~~

src/rust-lang-server.ts:164:33 - error TS2345: Argument of type 'LanguageClient' is not assignable to parameter of type 'Disposable'.

164       nova.subscriptions.remove(this.languageClient)
                                    ~~~~~~~~~~~~~~~~~~~

Found 4 errors in the same file, starting at: src/rust-lang-server.ts:66

Expected behavior The app build successfully.

Versions (please complete the following information):

Additional context

Looking through the Nova docs on subscriptions (which is a CompositeDisposable) the add method requires an object that has a dispose() method. The docs for LanguageClient don't specify that method.

So one question I'm asking myself is: should the extension be subscribing to the LanguageClient? Also, how did you compile this?

kilbd commented 1 year ago

It's been a while, so I can't comment on why I believed the client was disposable 😅. Thanks for scouring the docs for this issue! I'll work on fixing this error.

Also, how did you compile this?

Are you asking how I was able to work around compiler errors, or are you asking for improvements to the documentation? If the former, I edited the type files locally and never got around to upstreaming the changes to Definitely Typed. If the latter, please let me know what's unclear or if I missed documenting something. Thanks!

edwardloveall commented 1 year ago

If the former, I edited the type files locally and never got around to upstreaming the changes to Definitely Typed.

Ah ha, thanks. That's what I was after.

Thanks for looking at the bug. Let me know if I can help with the types or the extension. I've got bandwidth here and there.