node_modules/@types/googlemaps/index.d.ts 中的错误 -- 元组类型元素列表不能为空 [英] ERROR in node_modules/@types/googlemaps/index.d.ts -- A tuple type element list cannot be empty

查看:108
本文介绍了node_modules/@types/googlemaps/index.d.ts 中的错误 -- 元组类型元素列表不能为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试将 angular google maps - agm 库集成到我的 angular 项目中时,我遇到了这个错误:

某些配置或可能是我遗漏的东西,我正在这个项目中使用材料 6 和角度 6,感谢您的帮助

在终端控制台

node_modules/@types/googlemaps/index.d.ts(63,25) 中的错误:错误 TS1122:元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(72,25): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(94,15): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(100,18): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(106,20): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(115,26): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(121,15): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(130,28): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(155,29): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(167,22): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(176,23): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(185,23): 错误 TS1122: 元组类型元素列表不能为空.node_modules/@types/googlemaps/index.d.ts(3308,76):错误 TS2370:rest 参数必须是数组类型.

这是我所做的:

npm i @agm/corenpm i -D @types/googlemapsng 添加@angular-material-extensions/google-maps-autocomplete

app.module.ts

import { AgmCoreModule } from '@agm/core';从@angular-material-extensions/google-maps-autocomplete"导入 { MatGoogleMapsAutocompleteModule };@NgModule({声明:[AppComponent, ...],进口:[AgmCoreModule.forRoot({apiKey: 'YOUR_KEY',图书馆:['地方']}),MatGoogleMapsAutocompleteModule.forRoot(), ...],引导程序:[AppComponent]})导出类 AppModule {}

mycomponent.component.html

<mat-label>地址<<使用指令 >></mat-label><输入垫输入matGoogleMaps自动完成[国家]="德"(onAutocompleteSelected)="onAutocompleteSelected($event)"(onLocationSelected)="onLocationSelected($event)"></mat-form-field>

mycomponent.component.ts

<代码>...从谷歌地图"导入 {};@成分({选择器:......

src/index.d.ts

声明模块'googlemaps';

tsconfig.app.json

<代码> ...类型":[谷歌地图"]...

package.json

 "依赖项": {"@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-b​​rowser": "^6.1.0","@angular/platform-b​​rowser-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"},

<块引用>

遵循教程:使用的教程链接

解决方案:我不知道为什么以及如何,但回滚到旧版本对我有用!!但这不是我正在寻找的正确解决方案

您需要返回一个有效的版本.

在您的 package.json 文件中,特别选择旧版本:

<代码>...@types/googlemaps":3.26.15"...

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

解决方案

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"
...

这篇关于node_modules/@types/googlemaps/index.d.ts 中的错误 -- 元组类型元素列表不能为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆