Reputation: 15
I am currently stuck with my tsc build: May someone of you can help me out.
I was trying to build my Serverless project with nom run build
.
After some time I get following errors:
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
So I am defenitly lost there. May you need some info from my 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"
}
If you need additional information please let me know. Thank you.
Treueid this already: typescript: error TS2693: 'Promise' only refers to a type, but is being used as a value here
Upvotes: 1
Views: 1123
Reputation: 8651
I was running into the same issue with node-fetch
in a CDK project and fixed it by adding "DOM"
to the lib
array in my tsconfig.json
:
Before:
"lib": [
"es2018"
],
After:
"lib": [
"es2018",
"DOM"
],
Upvotes: 4