【发布时间】:2022-02-17 22:41:44
【问题描述】:
我正在尝试使用具有核心依赖项的某个库,但是当我传递他需要的那种类型的对象时,由于子库正在使用他自己的节点模块作为路径,因此会引发错误。
这是我导入的对象以及我如何传递它:
import { Construct } from "@aws-cdk/core";
import { CfnDataSource } from "@aws-cdk/aws-quicksight";
...
constructor(scope: Construct, id: string) {
...
this.quickSightCdk = new CfnDataSource(scope, 'QuickSight', {
...
但它会抛出一个不匹配的错误,因为 quickisight 在它自己的节点模块中查找对象:
Argument of type 'import("C:/git/monorepo/aws/node_modules/@aws-cdk/core/lib/construct-compat").Construct' is not assignable to parameter of type 'import("C:/git/monorepo/aws/node_modules/@aws-cdk/aws-quicksight/node_modules/@aws-cdk/core/lib/construct-compat").Construct'.
并排:
'import("C:/git/monorepo/aws/node_modules/@aws-cdk/core/lib/construct-compat").Construct'
'import("C:/git/monorepo/aws/node_modules/@aws-cdk/aws-quicksight/node_modules/@aws-cdk/core/lib/construct-compat").Construct'
我尝试在参数上传递“this”,但它不起作用,
TS2345: Argument of type 'this' is not assignable to parameter of type 'Construct'. Type 'MyStack' is not assignable to type 'Construct'
我已经尝试将这两个库更新到最新版本,但没有成功。 有什么建议吗?
【问题讨论】:
-
有什么更新吗?不要让你的问题悬而未决。
标签: amazon-web-services npm aws-cdk