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

Type-definitions #74

Closed
deser opened this issue Mar 3, 2020 · 14 comments
Closed

Type-definitions #74

deser opened this issue Mar 3, 2020 · 14 comments
Labels
feature request New feature requested

Comments

@deser
Copy link

deser commented Mar 3, 2020

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Need to add HTMLElement type on('move') handler for removed/added

@simonwep
Copy link
Owner

simonwep commented Mar 3, 2020

Excuse me? I'm not even providing ts-types for this package (at least not yet officially), do you mean this package?

@deser
Copy link
Author

deser commented Mar 4, 2020

Sure, but who supports that package? Not you? Maybe it's time to convert to typescrtipt or have your own types?

@simonwep
Copy link
Owner

simonwep commented Mar 4, 2020

Huh, if you're using selectionjs with ts you should have recognized type-search and how they maintain types. And don't you see that this package doesn't even contain ts-files? Neither I'm mentioning ts-support or types anywhere in the readme.

Types by TypeSearch is made for packages who are not actively supporting types, so there's no reason to publish your js-package and "polyfilling" your own project with types.

I won't rewrite the code-base just for the sake of ts - maybe I'll add types sooner or later, is it that what you want? Native ts-support?

@deser
Copy link
Author

deser commented Mar 4, 2020

I won't rewrite the code-base just for the sake of ts - maybe I'll add types sooner or later, is it that what you want? Native ts-support?

yeah :)

@simonwep simonwep changed the title Fix types for on 'move' Type-definitions Mar 4, 2020
@simonwep simonwep added the feature request New feature requested label Mar 4, 2020
@simonwep
Copy link
Owner

simonwep commented Apr 6, 2020

@deser I've added and updated the type-definitions for this package. Typings for the move-event were already available so you might have just used a really old version.

In case I'm wrong, could you please tell me what's missing in here?

@deser
Copy link
Author

deser commented Apr 10, 2020

Firstly, thanks a lot!

I think you need to change this at the top:

type ElementList = Element | readonly Element[] | NodeList | HTMLCollection | HTMLElement | HTMLElement[];

@simonwep
Copy link
Owner

Is that necessary? HTMLElement extends Element:
image

So theoretically that should be sufficient right?

type ElementList = Element | Element[] | HTMLCollection;

@deser
Copy link
Author

deser commented Apr 17, 2020

No, Element doesn't have necessary props which HTMLElement has :) Please, just add and release new version :)

@deser
Copy link
Author

deser commented Apr 21, 2020

@simonwep , so what? :)

@simonwep
Copy link
Owner

@deser If Element isn't sufficient - that should be enough right? Because you said that only HTMLElement contains the require properties:

type ElementList = NodeList  | HTMLCollection | HTMLElement | HTMLElement[];

Although NodeList can contain nodes which again are missing some of the properties :/

@deser
Copy link
Author

deser commented Apr 29, 2020

HTMLElement is ok. I think you can do the changes and publish package :)

@simonwep
Copy link
Owner

Woah, no need to stress with publishing a new version. v1.7.0 now includes type-definitions :)

@deser
Copy link
Author

deser commented Apr 29, 2020

Many thanks :)
Seems one more issue:
image
selected\added\removed - all of them are of ElementList type I think. I think most probably you need to add to Element | HTMLElement everywhere...

@simonwep
Copy link
Owner

simonwep commented Apr 30, 2020

These are always HTML elements so I can safely use HTMLElement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature requested
Projects
None yet
Development

No branches or pull requests

2 participants