簡體   English   中英

將 aws cdk 與 typescript 結合使用時出現許多構建錯誤

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM