-
Notifications
You must be signed in to change notification settings - Fork 125
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
[Bug] "Cannot find namespace google" on version => 1.1.1 #519
Comments
Hmm, there's gotta be more to this. Just created a fresh project to check, installed Can you check that Also, when is the error happening? There's something about |
for reference, when I try to do this: export default function Home() {
const foo = new google.maps.Polygon();
return (
// ...
);
} I get an error message like this:
|
I have just tried one of the examples provided using Im very confused. |
I see in the example project using
vs
manually installing that version of the types didnt resolve it either |
Further debugging shows its an issue with my Further, further debugging shows its an issue with the I dont know why this would have only come about in the latest versions, but it seems that you need to add
|
This is my current tsconfig. Ive also just noticed that simply removing the types array altogether also allows everything to work just fine.
|
It seems that this is more of a project configuration issue on my end, but whatever was generating that reference in the 1.1.0 version seems to make the library more robust. I think if possible, it would be good to bring that change to the later versions as well. |
Seems to be one of the changes of typescript 5.5: https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#simplified-reference-directive-declaration-emit Edit: having read that, it seems the default assumption is that the google.maps types, if needed, will already be in your project's configuration, and we have them in our dependencies to make sure they’re at least installed. As we directly use them (as part of our PropTypes for example), it would make sense to maintain such a reference in our types. That should probably just be once in the |
Typescript versions prior to 5.5 automatically emitted triple-slash directives for types used in the exported definitions. This was changed in 5.5, which could lead to situations where the google.maps types aren't properly picked up in a project using this package. Adding a type-reference ourselves should help in those cases. See https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#simplified-reference-directive-declaration-emit fixes visgl#519
Typescript versions prior to 5.5 automatically emitted triple-slash directives for types used in the exported definitions. This was changed in 5.5, which could lead to situations where the google.maps types aren't properly picked up in a project using this package. Adding a type-reference ourselves should help in those cases. See https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#simplified-reference-directive-declaration-emit fixes #519
I published 1.1.3, can you test this in your old setup to see if it is now working correctly? |
That did it! I added my types array back to the tsconfig and omitted google.maps, bumped to v1.1.3. Everything seems to be working fine now. Thanks for getting this resolved so quickly. |
Description
Since updating to version
1.1.1
and1.1.2
from1.1.0
, I am no longer able to build my project as the google namespace is not available.Hard coding
1.1.0
and reinstalling works perfectly.Including
@types/google.maps
with the updated library version also did not seem to work.Steps to Reproduce
Set your dependency version to
"@vis.gl/react-google-maps": "^1.1.1"
or"@vis.gl/react-google-maps": "^1.1.2",
Define a polygon object - or anything else from
google.maps
let polygon: google.maps.Polygon
Environment
Logs
No response
The text was updated successfully, but these errors were encountered: