google-maps-services-js icon indicating copy to clipboard operation
google-maps-services-js copied to clipboard

Typescript errors when building

Open palfaro91 opened this issue 2 years ago • 10 comments

Hello, When I run the build command in an Adonisjs I get various Typescript errors that prevent build unless I ignore the errors

node_modules/@googlemaps/google-maps-services-js/src/client.ts:107:12 - error TS2345: 
Argument of type 'import("/Users/foolio/Sites/test-api/node_modules/@googlemaps/google-maps-services-js/node_modules/axios/index").AxiosInstance' is not assignable to parameter of type 'import("/Users/foolio/Sites/test-api/node_modules/axios/index").AxiosInstance'.
  Types of property 'defaults' are incompatible.
    Type 'AxiosDefaults<any>' is not assignable to type 'Omit<AxiosDefaults<any>, "headers"> & { headers: HeadersDefaults & { [key: string]: AxiosHeaderValue; }; }'.
      Type 'AxiosDefaults<any>' is not assignable to type 'Omit<AxiosDefaults<any>, "headers">'.
        Types of property 'adapter' are incompatible.
          Type 'AxiosAdapter | undefined' is not assignable to type 'AxiosAdapterConfig | AxiosAdapterConfig[] | undefined'.
            Type 'AxiosAdapter' is not assignable to type 'AxiosAdapterConfig | AxiosAdapterConfig[] | undefined'.
              Type 'import("/Users/foolio/Sites/test-api/node_modules/@googlemaps/google-maps-services-js/node_modules/axios/index").AxiosAdapter' is not assignable to type 'import("/Users/foolio/Sites/test-api/node_modules/axios/index").AxiosAdapter'.
                Types of parameters 'config' and 'config' are incompatible.
                  Type 'InternalAxiosRequestConfig<any>' is not assignable to type 'AxiosRequestConfig<any>'.
                    Types of property 'paramsSerializer' are incompatible.
                      Type 'ParamsSerializerOptions | undefined' is not assignable to type '((params: any) => string) | undefined'.
                        Type 'ParamsSerializerOptions' is not assignable to type '(params: any) => string'.
                          Type 'ParamsSerializerOptions' provides no match for the signature '(params: any): string'.

107 rax.attach(defaultAxiosInstance);
node_modules/@googlemaps/google-maps-services-js/src/client.ts:159:18 - error TS2345: Argument of type 'import("/Users/foolio/Sites/test-api/node_modules/@googlemaps/google-maps-services-js/node_modules/axios/index").AxiosInstance' is not assignable to parameter of type 'import("/Users/foolio/Sites/test-api/node_modules/axios/index").AxiosInstance'.
node_modules/@googlemaps/google-maps-services-js/src/client.ts:177:5 - error TS2322: Type 'null' is not assignable to type 'string[]'.
node_modules/@googlemaps/google-maps-services-js/src/directions.ts:215:45 - error TS2488: Type 'LatLng[] | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.
node_modules/@googlemaps/google-maps-services-js/src/places/queryautocomplete.ts:20:3 - error TS6133: 'Place' is declared but its value is never read.

Thanks for stopping by to let us know something could be better!

Environment details

  1. Specify the API at the beginning of the title (for example, "Places: ...") I'm using this library in an Adonis Js project.

  2. OS type and version MacOs Monterey 12.5.1

  3. Library version and other environment information Version 3.3.27 this version requires axios 0.27.2

Steps to reproduce

  1. In an Adonisjs project add a custom route and then run npm run build

Stack trace

Line numbers included in errors above.

palfaro91 avatar Feb 24 '23 20:02 palfaro91

If you would like to upvote the priority of this issue, please comment below or react with :+1: so we can see what is popular when we triage.

@palfaro91 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 Feb 24 '23 20:02 wangela

Any word?

palfaro91 avatar Mar 13 '23 18:03 palfaro91

Until they've fixed it in the repository, you can revert all the breaking changes made by the dependency bot in your local environment.

The bot upgraded quite a lot of packages with major version updates, including breaking changes.

git checkout fb5dc053f685939a6493e43a8ac3a3529cc06696

nora-soderlund avatar Mar 31 '23 10:03 nora-soderlund

Until they've fixed it in the repository, you can revert all the breaking changes made by the dependency bot in your local environment.

The bot upgraded quite a lot of packages with major version updates, including breaking changes.

git checkout fb5dc053f685939a6493e43a8ac3a3529cc06696

@nora-soderlund Thanks for the tip! So that would mean downgrading down to ^3.3.26 in package.json?

palfaro91 avatar Mar 31 '23 19:03 palfaro91

This should be fixed in the latest release from this afternoon

amuramoto avatar Apr 01 '23 02:04 amuramoto

Hi @amuramoto I just updated my package to 3.3.37 and I'm still getting the same errors.

palfaro91 avatar Sep 09 '23 06:09 palfaro91

@amuramoto I'm also using axios in my project and if I downgrade down to the same version that this package requires (0.27.2) the axios errors go away.

node_modules/@googlemaps/google-maps-services-js/src/client.ts:177:5 - error TS2322: Type 'null' is not assignable to type 'string[]'.

177     this.experienceId = null;

for this error it looks like the declaration should be updated to private experienceId: string[] | null; if null should be an accepted value

for this error

node_modules/@googlemaps/google-maps-services-js/src/directions.ts:215:45 - error TS2488: Type 'LatLng[] | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.

215     params.waypoints = ["optimize:true", ...params.waypoints];

For this error it looks like making waypoints optional is throwing the compiler off. It should be cast as an array

node_modules/@googlemaps/google-maps-services-js/src/places/queryautocomplete.ts:20:3 - error TS6133: 'Place' is declared but its value is never read.

20   Place,

It looks like the Place variable should be removed because it's not used

palfaro91 avatar Sep 09 '23 07:09 palfaro91

@amuramoto so I'm also using axios in my project but using version 1.5.0. When I build my project it tries to use my version instead of the required version 0.27.2 and it looks like it's the axios-retry peer dependency that is causing it to use the root axios version


      "peerDependencies": {
        "axios": "*"
      }

palfaro91 avatar Sep 11 '23 19:09 palfaro91

Hi @wangela any word on this fix?

palfaro91 avatar Jan 10 '24 22:01 palfaro91

Is this ever going to be fixed @wangela ?

palfaro91 avatar Jun 14 '24 20:06 palfaro91