[英]Many build errors while using aws cdk in combination with typescript
我目前坚持使用我的 tsc 构建:愿你们中的某个人可以帮助我。
我试图用nom run build
构建我的无服务器项目。
一段时间后,我收到以下错误:
lambda-fun/fetch-notification.ts:13:22 - error TS2694: Namespace '"/Users/elmar/dev/my-project/node_modules/aws-cdk-lib/aws-lambda/index"' has no exported member 'APIGatewayProxyEventV2'.
13 event: awsLambda.APIGatewayProxyEventV2,
lambda-fun/fetch-notification.ts:14:22 - error TS2694: Namespace '"/Users/elmar/dev/my-project/node_modules/aws-cdk-lib/aws-lambda/index"' has no exported member 'APIGatewayProxyResultV2'.
14 ): Promise<awsLambda.APIGatewayProxyResultV2> {
node_modules/fetch-blob/file.d.ts:1:76 - error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
1 /** @type {typeof globalThis.File} */ export const File: typeof globalThis.File;
node_modules/fetch-blob/from.d.ts:20:64 - error TS2749: 'File' refers to a value, but is being used as a type here. Did you mean 'typeof File'?
20 export function fileFrom(path: string, type?: string): Promise<File>;
node_modules/fetch-blob/from.d.ts:25:60 - error TS2749: 'File' refers to a value, but is being used as a type here. Did you mean 'typeof File'?
25 export function fileFromSync(path: string, type?: string): File;
node_modules/fetch-blob/index.d.ts:2:38 - error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
2 export const Blob: typeof globalThis.Blob;
node_modules/formdata-polyfill/esm.min.d.ts:2:11 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
2 new (): FormData;
node_modules/formdata-polyfill/esm.min.d.ts:3:14 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
3 prototype: FormData;
node_modules/formdata-polyfill/esm.min.d.ts:5:50 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
5 export declare function formDataToBlob(formData: FormData): Blob;
node_modules/node-fetch/@types/index.d.ts:124:4 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
124 | FormData
node_modules/node-fetch/@types/index.d.ts:137:22 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?
137 formData(): Promise<FormData>;
Found 11 errors in 6 files.
Errors Files
2 lambda-fun/fetch-notification.ts:13
1 node_modules/fetch-blob/file.d.ts:1
2 node_modules/fetch-blob/from.d.ts:20
1 node_modules/fetch-blob/index.d.ts:2
3 node_modules/formdata-polyfill/esm.min.d.ts:2
2 node_modules/node-fetch/@types/index.d.ts:124
所以我肯定迷路了。 你可能需要我的package.json
的一些信息:
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"test": "jest",
"cdk": "cdk"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.104",
"@types/jest": "^28.1.6",
"@types/node": "18.7.18",
"@types/node-fetch": "^2.6.2",
"@types/prettier": "2.7.0",
"@types/uuid": "^8.3.4",
"aws-cdk": "2.41.0",
"constructs": "^10.1.71",
"esbuild": "^0.15.0",
"jest": "^28.1.3",
"ts-jest": "^28.0.7",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"dependencies": {
"@aws-cdk/aws-dynamodb": "^1.169.0",
"aws-cdk-lib": "^2.41.0",
"aws-sdk": "^2.1217.0",
"constructs": "^10.0.0",
"fast-xml-parser": "^4.0.9",
"fetch": "^1.1.0",
"node-fetch": "^3.2.10",
"source-map-support": "^0.5.21",
"twitter-api-sdk": "^1.1.0",
"ulid": "^2.3.0",
"uuid": "^8.3.2"
}
如果您需要更多信息,请告诉我。 谢谢你。
Treueid 这已经: typescript:错误 TS2693:“承诺”仅指一种类型,但在此处用作值
我在 CDK 项目中遇到了与node-fetch
相同的问题,并通过将"DOM"
添加到我的tsconfig.json
中的lib
数组来修复它:
前:
"lib": [
"es2018"
],
后:
"lib": [
"es2018",
"DOM"
],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.