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

Add Typescript support #152

Open
tobiasbueschel opened this issue Nov 18, 2023 · 5 comments
Open

Add Typescript support #152

tobiasbueschel opened this issue Nov 18, 2023 · 5 comments
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tobiasbueschel
Copy link

Is your feature request related to a problem? Please describe.
I've integrated @googlemaps/extended-component-library into a React application and noticed that Typescript is not yet supported.

image

I've also installed @types/google.maps, but it doesn't contain type annotations for these extended components.

Describe the solution you'd like
It would be great to include the types in this library or e.g., @types/google.maps.

@tobiasbueschel tobiasbueschel added triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Nov 18, 2023
@wangela
Copy link
Member

wangela commented Nov 18, 2023

If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.

@tobiasbueschel Thank you for opening this issue. 🙏
Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

@leafsy
Copy link
Collaborator

leafsy commented Nov 28, 2023

Hi @tobiasbueschel , could you try setting moduleResolution to either "node16" or "bundler" in your project's tsconfig.json? (see TS Docs on the distinction and related question)

@leafsy leafsy removed the triage me I really want to be triaged. label Nov 28, 2023
@mbench757
Copy link

While the specific issue can be solved by adding "/lib/" in the path, like this: @googlemaps/extended-component-library/lib/react, it is still very frustrating that there are a lot of issues when creating a .tsx file, based on the samples. Simply copying class App into a .tsx file has many issues. Very frustrating that this library is not plug and play.

@rek
Copy link

rek commented Aug 29, 2024

the lib in the path didn't fix things for us, so we are just removing the types for now, adding:

// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../../types.d.ts" />

and types.d.ts

declare module '@googlemaps/extended-component-library/react' {
  // Disable type checking for the named export `PlacePicker`
  export const PlacePicker: any;
}

which is a horrible work-around, but it let's us keep moving for now.

@HMubaireek
Copy link

Adding it to the paths in the main tsconfig.json for your project would solve the issue too:

"paths": {
      "@googlemaps/extended-component-library/react": [
        "node_modules/@googlemaps/extended-component-library/lib/react"
      ]
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

6 participants