我如何在我的Vuejs项目中迁移aws-amplify来使用Typescript?



我有一个现有的Vuejs2项目,我最近刚刚升级到Typescript:

vue add typescript

我现在看到这个错误,我不能找到答案在谷歌搜索:

DONE  Compiled successfully in 2386ms                                1:49:51 PM
ERROR in .../front-end/src/main.ts(19,9):
19:9 No overload matches this call.
Overload 1 of 2, '(plugin: PluginObject<unknown> | PluginFunction<unknown>, options?: unknown): VueConstructor<Vue>', gave the following error.
Argument of type 'typeof import(".../front-end/node_modules/aws-amplify/lib-esm/index")' is not assignable to parameter of type 'PluginObject<unknown> | PluginFunction<unknown>'.
Property 'install' is missing in type 'typeof import(".../front-end/node_modules/aws-amplify/lib-esm/index")' but required in type 'PluginObject<unknown>'.
Overload 2 of 2, '(plugin: PluginObject<any> | PluginFunction<any>, ...options: any[]): VueConstructor<Vue>', gave the following error.
Argument of type 'typeof import(".../front-end/node_modules/aws-amplify/lib-esm/index")' is not assignable to parameter of type 'PluginObject<any> | PluginFunction<any>'.
Property 'install' is missing in type 'typeof import(".../front-end/node_modules/aws-amplify/lib-esm/index")' but required in type 'PluginObject<any>'.
17 | })
18 | 
> 19 | Vue.use(AmplifyModules)
|         ^
20 | Vue.use(VuetifyConfirm, {
21 |   vuetify,
22 |   buttonFalseColor: "primary",
Version: typescript 4.1.6
Time: 1727ms
App running at:
- Local:   http://localhost:8080/ 
- Network: http://192.168.1.149:8080/

我在包中的依赖项。json包含"aws-amplify": "^1.3.3"

我对Typescript很陌生,不知道为什么它找不到安装方法,或者我可以显式地给它什么类型来使插件工作。值得注意的是,我的应用程序似乎仍然可以正常编译和工作。包括影响登录过程的AWS Amplify元素。

谁知道如何摆脱这个错误消息和满足Typescript?

看起来您可能需要将aws-amplify更新为当前版本为4.2.3(参见https://www.npmjs.com/package/aws-amplify)

最新更新