Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(tests): type check packages/neovim/*.test.ts #411

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

gjf7
Copy link
Contributor

@gjf7 gjf7 commented Oct 10, 2024

Follow up #410, for #352.

"include": ["src", "**/api/Buffer.test.ts"],
"exclude": ["node_modules", "__tests__", "**/*.test.ts", "examples", "lib"]
"include": ["src"],
"exclude": ["node_modules", "examples", "lib"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, so we can close #352 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, still need to work on packages/integration-tests/.

@@ -218,7 +222,7 @@ describe('Neovim API', () => {
const numWindows = (await nvim.windows).length;
const buffer = await nvim.createBuffer(false, false);
expect(await nvim.buffers).toHaveLength(numBuffers + 1);

assert(buffer instanceof Buffer);
Copy link
Member

@justinmk justinmk Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's a typescript or tsserver bug, but locally I had to do this (similar for the other instanceof checks below):

Suggested change
assert(buffer instanceof Buffer);
assert(typeof buffer !== 'number');

The nvim.openWindow and related signatures are kind of weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok on my mac and ci. Anyway, I changed this to assert(typeof buffer !== 'number').

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nvim.openWindow and related signatures are kind of weird.

Yeah, I think we can improve this in future.

@@ -232,7 +232,7 @@ export class Neovim extends BaseApi {
/**
* Sets the current tabpage
*/
set tabpage(tabpage: AsyncTabpage) {
set tabpage(tabpage: AsyncTabpage | Tabpage) {
this.request(`${this.prefix}set_current_tabpage`, [tabpage]);
Copy link
Member

@justinmk justinmk Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this and the buffer() case were a hidden bug. Do they need the same treatment as in window()? I don't see anywhere in this.request codepath that would implicitly handle a Promise (AsyncBuffer/AsyncTabpage)

    if (tabpage instanceof Tabpage) {
      this.request(`${this.prefix}set_current_tabpage`, [tabpage]);
    } else {
      tabpage.then(tabpage => this.request(`${this.prefix}set_current_tabpage`, [tabpage]));
    }

@justinmk
Copy link
Member

#411 (comment) doesn't need to block this, but might need a fix.

@justinmk justinmk merged commit a7d6c78 into neovim:master Oct 10, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants