-
Notifications
You must be signed in to change notification settings - Fork 72
fix the signatures of importLibrary #1161
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
Conversation
|
Also I think the docs should be updated to remove the cast:
|
Maybe I misunderstand you, but what that signature actually does is define our (note also that the Our own implementation (APILibraryMap etc) will be removed once the @types/google.maps package has been updated with better typings. |
|
What I mean by "The variadic signature is not implemented" is that you can not |
|
Yes, but that's fully intentional. We wanted to stick to the rather minimalist implementation of dynamic library loading available here: https://developers.google.com/maps/documentation/javascript/load-maps-js-api, but have it in a way better suited for projects using bundlers etc. Loading multiple libraries at once isn't trivial to solve due to the handling of the return values, and everything we looked at missed some important points or felt weird in some way. If you need parts of different libraries, there's nothing wrong with loading them sequentially, or using One more thing: Thanks for the remark on the docs! I'll forward that to someone at google who can take care of that. |
|
We seem to agree that loading multiple libraries is not implemented, right? The current code says it: Lines 104 to 106 in 5e3bffb
What this PR does is to remove that signature so that typescript correctly report that try to becomes a type error. Without this PR, TS is happy with As I added in the PR description, the following is now typed as expected: With the 2 overrides, you can verify that: const m = await importLibrary("maps");
const m2 = await importLibrary("not-maps");
So I believe the PR is right and should have been merged instead of being closed? (say hello to Chris JS for me) |
|
Here's a typescript playground isolating this part of our types. What you can see there: as long as there's a working definition of Eventually, we want to solely rely on the types from the |
|
@usefulthink you are absolutely right? I just tested this again and it's WAI. I must have had another issue before (probably "as long as there's a working definition of google.maps.importLibrary"). Sorry for the noise! |

Thank you for opening a Pull Request!
The variadic signature is not implemented so it is not usable (the implementation would have to take a
string[]) so I removed it.With the 2 overrides, you can verify that:
mis agoogle.maps.MapsLibrarym2isunknownBefore submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕