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

Emittery.mixin type is no longer valid for classes with args in their constructor #79

Closed
davidmurdoch opened this issue Feb 23, 2021 · 1 comment

Comments

@davidmurdoch
Copy link
Contributor

TypeScript v4.1.5
Emittery v0.8.1

@Emittery.mixin("emittery")
class MyClass {
  constructor(arg: string){
    
  }
}

errors with:

Argument of type 'typeof MyClass' is not assignable to parameter of type 'new () => any'.
  Types of construct signatures are incompatible.
    Type 'new (arg: string) => MyClass' is not assignable to type 'new () => any'.ts(2345)

Maybe this type should be more like:

	static mixin(
		emitteryPropertyName: string | symbol,
		methodNames?: readonly string[]
	): <T extends { new (...args: any): any }>(klass: T) => T; 

(I haven't really tested this type)

@sindresorhus
Copy link
Owner

Maybe this type should be more like:

Yeah, I think it should.


// @airhorns

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

2 participants