Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR in node_modules/@types/googlemaps/index.d.ts -- A tuple type element list cannot be empty

while trying to integrate the angular google maps - agm librarie in my angular project i got this error :

somthing is worng with some configuration or maybe something i have missed i m working with material 6 and angular 6 in this project thanks for your help

in terminal console

ERROR in node_modules/@types/googlemaps/index.d.ts(63,25): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(72,25): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(94,15): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(100,18): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(106,20): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(115,26): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(121,15): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(130,28): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(155,29): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(167,22): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(176,23): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(185,23): error TS1122: A tuple type element list cannot be empty.
node_modules/@types/googlemaps/index.d.ts(3308,76): error TS2370: A rest parameter must be of an array type.

here is what i did :

npm i @agm/core 
npm i -D @types/googlemaps 
ng add @angular-material-extensions/google-maps-autocomplete

app.module.ts

import { AgmCoreModule } from '@agm/core';
import { MatGoogleMapsAutocompleteModule } from '@angular-material-extensions/google-maps-autocomplete';

@NgModule({
  declarations: [AppComponent, ...],
  imports: [
     AgmCoreModule.forRoot({
          apiKey: 'YOUR_KEY',
          libraries: ['places']
        }),
     MatGoogleMapsAutocompleteModule.forRoot(), ...],  
  bootstrap: [AppComponent]
})
export class AppModule {
}

mycomponent.component.html

<mat-form-field>
  <mat-label>Address << using the directive >></mat-label>
  <input matInput
       matGoogleMapsAutocomplete
       [country]="de"
       (onAutocompleteSelected)="onAutocompleteSelected($event)"
       (onLocationSelected)="onLocationSelected($event)">
</mat-form-field>

mycomponent.component.ts

...
import {} from 'googlemaps';



@Component({
  selector : ...
...

src/index.d.ts

declare module 'googlemaps';

tsconfig.app.json

    ...
   "types": [
      "googlemaps"
    ]
   ...

package.json

 "dependencies": {
    "@agm/core": "^1.1.0",
    "@angular-material-extensions/google-maps-autocomplete": "^2.0.0",
    "@angular/animations": "^6.1.10",
    "@angular/cdk": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/material": "^6.1.0",
    "@angular/material-moment-adapter": "^8.2.3",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "googleapis": "28.1.0",
    ...
    "@types/googlemaps": "^3.39.0",
    "rxjs": "^6.5.3",
    "rxjs-compat": "^6.5.3",
    "zone.js": "~0.8.26"
  },

followed tutorial : link to tuto used

Solution : i don't know why and how but rolling back to an older version worked for me !! but that's not the proper solution i looking for

like image 799
ZINE Mahmoud Avatar asked Dec 24 '19 18:12

ZINE Mahmoud


3 Answers

downgrade your version of googlemapps https://www.npmjs.com/package/@types/googlemaps/v/3.38.0

run the command npm i @types/[email protected]

like image 165
AtLeastTheresToast Avatar answered Oct 16 '22 06:10

AtLeastTheresToast


You need to go back to a version that works.

In your package.json file, choose an older version specifically:

...    
"@types/googlemaps" :  "3.26.15"
...
like image 34
Sol Solomon Avatar answered Oct 16 '22 08:10

Sol Solomon


I am getting the same error as defined above. but when I go to file in nodemodules/@types/GoogleMaps and open file index.d.ts. I see lot of functions there as shown in fig. for example we have a function bounds_changed: []; when I changed this function to bounds_changed:[''] it is working fine but we need an exact solution how to fix this because we are installing node modules every time when we create a build.

interface MapHandlerMap { /** * This event is fired when the viewport bounds have changed. * @see {@link https://developers.google.com/maps/documentation/javascript/reference/map#Map.bounds_changed Maps JavaScript API} * @see {@link Map#getBounds} * @see {@link Map#fitBounds} * @see {@link Map#panToBounds} */ bounds_changed: [];

    /**
     * This event is fired when the map center property changes.
     * @see {@link https://developers.google.com/maps/documentation/javascript/reference/map#Map.center_changed Maps JavaScript API}
     * @see {@link MapOptions#center}
     * @see {@link Map#getCenter}
     * @see {@link Map#setCenter}
     */
    center_changed: [];
like image 3
Bushart hussain Avatar answered Oct 16 '22 08:10

Bushart hussain