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

typings don't allow signals without parameters #46

Open
jmlee2k opened this issue Jun 19, 2024 · 0 comments
Open

typings don't allow signals without parameters #46

jmlee2k opened this issue Jun 19, 2024 · 0 comments

Comments

@jmlee2k
Copy link

jmlee2k commented Jun 19, 2024

example:

import { MiniSignal } from "mini-signals";

const noParamSignal = new MiniSignal<never>();
noParamSignal.add(()=>console.log(`recieved`));

//Argument of type '[]' is not assignable to parameter of type 'never'.ts(2345)
noParamSignal.dispatch();

I believe the general solution may be to switch the T generic from:

T extends any[] = any[]

to

T extends any[] | void = void

but this is complicated by the fact that the dispatch method expects an array (due to it's use of the spread syntax)

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