gpt4 book ai didi

angular - node_modules/@types/googlemaps/index.d.ts中的错误-元组类型元素列表不能为空

转载 作者:行者123 更新时间:2023-12-03 16:00:12 27 4
gpt4 key购买 nike

在尝试将 Angular 形Google map -agm librarie集成到我的 Angular 形项目中时,出现以下错误:

有些东西有些破旧,或者我在本项目中使用 Material 6和 Angular 钢6时可能错过了一些东西,谢谢您的帮助

终端控制台中的

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.

这是我所做的:
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



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

最佳答案

您需要回到可以使用的版本。
package.json文件中,专门选择一个较旧的版本:

...    
"@types/googlemaps" : "3.26.15"
...

关于angular - node_modules/@types/googlemaps/index.d.ts中的错误-元组类型元素列表不能为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59472584/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com