-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(popper): Improved type definitions #367
Conversation
@giladgray these changes will break the newly created |
Waiting for @giladgray feedback to merge this. I'm willing to merge this because the type definitions introduced in 1.11.0 are actually breaking changes to the previous version so it's okay to "break" them to reintroduce stability with the previous ones. |
I'm going to need some time to think about this change. The move to put everything in In the short term, please remove |
The thing is that I see that with your way to define types people have to import them all with something like I really like to be able to use |
@giladgray I can see where you're coming from but I think the more pressing issue is that the new definition files included with the library break typescript builds relying on the external types, as @FezVrasta mentioned above. This is something that can only be fixed by using the old structure for now, and if the new structure is an improvement (and I can see where you're coming from, I just need to research it a bit more to be sure of things) then it should be added in the 2.0 release. |
I've made this gist that I've tested and works. It is similar to what you were doing @giladgray, however it retains support for However, popper.js when used as a standalone library adds a @FezVrasta what are your thoughts on this? I can't see a reason to make Popper an import only library due to the number of people that don't use module loaders. Please forgive me if I'm completely off the mark here! |
I haven't enough knowledge of TypeScript to give meaningful feedbacks, the only reason I'm willing to merge this PR is to fix the API contract with previous versions. |
@edcarroll the idea behind the types here is you should not need |
also, have you folks tried this import strategy? it should be the new way: import Popper, { Modifiers, Placement } from "popper.js"
// Popper is a real JS constructor, Modifers & Placement are just TS types |
@giladgray don't worry I'm not trying to debate whether the types should be included - I'm fully aware of the benefits of including the types here (and am very happy they are being included 😄) - the point I'm trying to make is the currently included typings have broken the builds for everyone using the (now defunct) external ones as you've modified how the types must be imported. I know you can just uninstall them but the point is (as @FezVrasta has mentioned a few times as well) that right now they're a breaking change and so shouldn't be included in the form you've suggested until version 2 - do you see what I mean? Regarding the import strategy you've just mentioned, I wasn't aware of it at all and do quite like it! Btw, do you see what I mean regarding the global namespace and the fact that the |
Could we provide both methods together? |
We got this issue #369 If it can be fixed merging this PR I'm willing to merge this as is, then you guys can improve the type definitions however you like, I just care to have the library in a stable situation |
@FezVrasta my PR should fix this error - I believe it's due to |
@giladgray and @edcarroll, as I said, feel free to send PRs to improve the current definitions. I don't have experience with TypeScript so I can't be of any help unfortunately. |
sounds good, will do when i have some time |
@edcarroll about it breaking I could submit a PR that literally just changes this line: https://github.com/souporserious/react-popper/blob/master/react-popper.d.ts#L3:L3 to
if you think that's sufficient. |
@rajington it does need to be updated indeed, as it relies on type definitions that aren't in place anymore. I think the change you've mentioned should be sufficient, the other changes made don't appear to affect the usage in that file. Thanks 😄 |
The typings in popper.js were [updated recently](floating-ui/floating-ui#367 (comment)), causing issues. I believe this fix is sufficient and so does the [update's author](floating-ui/floating-ui#367 (comment)) but I would like to verify with someone if this is the right step.
I have a few bits of feedback here:
|
I'm really losing hope with all this TypeScript shit... Please send PRs and discuss with the other interested people about all this problems. |
@FezVrasta I hear you, definitely frustrating to get started with writing typedefs. Hopefully the community that cares about typedefs can handle it without your involvement. If someone wants to be in charge of it, maybe @adidahiya since he seems knowledgeable about the matter, you could create a code owners file for the typedef file only. In general the direction is trying to move away from DefinitelyTyped, but if it's a big enough problem for you, going back to that is always an option. And thanks for the library. |
@FezVrasta hey, sorry about that, my intention wasn't to blame you or cause additional stress -- I do intend to help contribute here and take on some of the maintenance burden. I wanted to post my comment here so that I'd be sure the interested parties would see it. I'll move further discussion to a new PR. Thanks for the library! |
no problem guys, I'm just already against TypeScript (I use Flow) and seeing all this churn around a so simple feature makes me hate that damn thing even more 🙄 |
Anyone here having problems with these typings? I have an issue that's stably reproducible, but not sure if this is an issue with popper.js typings or react-popper typings. Steps to reproduce:
Compilation always fails with:
Any suggestions? |
Fixes issues introduced by included type definitions conflicting with
@types
definitions.Also includes improved modifier definitions, as well as exposing the
options
property on thePopper
class.