ค้นหาเว็บไซต์

node.js - พบข้อผิดพลาดใน TypeScript (TS2430 และ TS2344): อินเทอร์เฟซ 'Response' ขยายอินเทอร์เฟซ 'ServerResponse' อย่างไม่ถูกต้อง


ฉันกำลังสร้าง API แบ็กเอนด์ร้านค้าออนไลน์ใน Node และ Express เมื่อทำการแปลงไฟล์ (.ts) เป็น (.js) ฉันได้รับข้อผิดพลาดนี้ ขึ้นอยู่กับโปรเจกต์ของฉันมีดังนี้:

"@types/express": "^4.17.12", "@types/express-serve-static-core": "^4.17.21", "@types/node": "^15.12.4", "bcrypt": "^5.0.1", "body-parser": "^1.19.0", "db-migrate": "^0.11.12", "db-migrate-pg": "^1.2.2", "dotenv": "^10.0.0", "express": "^4.17.1", "jasmine": "^3.7.0", "pg": "^8.6.0", "typescript": "^3.9.7"

"@types/bcrypt": "^5.0.0", "@types/jasmine": "^3.6.3", "@types/pg": "^7.14.11", "cross-env": "^7.0.3", "jasmine-spec-reporter": "^6.0.0", "jasmine-ts": "^0.3.0", "ts-node": "^9.1.1", "tsc-watch": "^4.2.9"

ข้อผิดพลาดที่ฉันได้รับคือ:

../node_modules/@types/express-serve-static-core/index.d.ts(589,18): ข้อผิดพลาด TS2430: อินเทอร์เฟซ 'Response' ขยายอินเทอร์เฟซ 'ServerResponse' ไม่ถูกต้อง คุณสมบัติ 'req' เป็นตัวเลือกในประเภท 'Response' แต่จำเป็นในประเภท 'ServerResponse' ../node_modules/@types/express/index.d.ts(58,55): ข้อผิดพลาด TS2344: ประเภท 'Response>' ไม่สอดคล้องกับข้อจำกัด 'ServerResponse' คุณสมบัติ 'req' เป็นตัวเลือกในประเภท 'Response>' แต่จำเป็นในประเภท 'ServerResponse'