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

Running type tests on CI #93

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Running type tests on CI #93

wants to merge 4 commits into from

Conversation

alexreardon
Copy link
Owner

Hey @Andarist it looks like the type tests I setup are now failing as a part of #44. I will have a go at fixing them

@github-actions
Copy link

github-actions bot commented Feb 2, 2023

size-limit report 📦

Path Size
dist/index.js 549 B (0%)

@alexreardon
Copy link
Owner Author

I think I will run these as standard jest tests

listener(event: MouseEvent) {
const value: number = event.button;
listener(event) {
expectTypeOf(event).toEqualTypeOf<MouseEvent>();
Copy link
Owner Author

Choose a reason for hiding this comment

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

@Andarist this is currently failing as event is being inferred by TS as any

Copy link
Owner Author

Choose a reason for hiding this comment

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

Any suggestion on how to resolve this?

export type Listener<TTarget extends EventTarget, TEvent extends Event> =
| ListenerObject<TEvent>
| { (this: TTarget, ev: TEvent): void };
export type Listener<TTarget extends EventTarget, TType extends string = string> =
Copy link
Owner Author

Choose a reason for hiding this comment

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

@Andarist I am keen for your thoughts here. I

moved Listener back to taking a string rather than an Event in order to maintain the previous type signature. Autocomplete seems to be continuing to work great.

Copy link
Owner Author

Choose a reason for hiding this comment

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

After this change the only breaking change would be the type signature of bindAll

Copy link
Owner Author

Choose a reason for hiding this comment

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

Or this is bad because we have separate calculating of what TEvent is, rather that a single inference at the root? 🤔

@alexreardon
Copy link
Owner Author

With all my type changes reverted, i am currently getting the event as any when bindAll has more than a single binding passed in @Andarist

Screenshot 2023-02-02 at 3 45 48 pm

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.

1 participant