extended-component-library icon indicating copy to clipboard operation
extended-component-library copied to clipboard

Add Typescript support

Open tobiasbueschel opened this issue 2 years ago • 5 comments

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 avatar Nov 18 '23 17:11 tobiasbueschel

If you would like to upvote the priority of this issue, please comment below or react on the original post above with :+1: 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.

wangela avatar Nov 18 '23 17:11 wangela

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 avatar Nov 28 '23 20:11 leafsy

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.

mbench757 avatar Apr 05 '24 17:04 mbench757

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.

rek avatar Aug 29 '24 06:08 rek

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"
      ]
    }

HMubaireek avatar Sep 05 '24 08:09 HMubaireek