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

Typescript: Template class extend Hookable type issue #97

Open
LeVieuxSinge opened this issue Feb 21, 2024 · 0 comments
Open

Typescript: Template class extend Hookable type issue #97

LeVieuxSinge opened this issue Feb 21, 2024 · 0 comments

Comments

@LeVieuxSinge
Copy link

LeVieuxSinge commented Feb 21, 2024

Environment

hookable: v5.5.3
node: v18.18.0

Reproduction

https://stackblitz.com/edit/hookable-extend-issue?file=src%2Fmain.ts&terminal=dev

Describe the bug

When trying to extend a template class with Hookable, the "callHook" method always returns a type error. It seems it always thinks there's an array ([]) argument passed as second parameter.

The following code:

import { Hookable } from 'hookable';

type MyHooks = {
  test: () => void;
};

class MyTemplateClass<T extends MyHooks = MyHooks> extends Hookable<T> {
  test() {
    this.callHook('test');
  }
}

Gives the following Typescript error for this.callHook('test');:

Argument of type '[]' is not assignable to parameter of type 'Parameters<InferCallback<T, "test">>'

Additional context

No response

Logs

No response

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

No branches or pull requests

1 participant