From 36b06be8ce0a85c9d4698f357405ea79170dde04 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 22 Mar 2023 13:29:46 +0100 Subject: [PATCH] chore: extend lint:ts to cover api (#49793) * fix: include express-session types + suppress err * chore: add api to lint:ts * fix: remove unnecessary typeRoots config --- api/index.ts | 2 ++ api/package.json | 3 ++- api/tsconfig.json | 3 +-- package.json | 2 +- pnpm-lock.yaml | 8 ++++++++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/api/index.ts b/api/index.ts index 4d7ecb5f18b..e88c04a721b 100644 --- a/api/index.ts +++ b/api/index.ts @@ -53,6 +53,8 @@ const start = async () => { // NOTE: Awaited to ensure `.use` is registered on `fastify` await fastify.register(middie); await fastify.register(fastifyCookie); + // @ts-expect-error - @fastify/session's types are not, yet, compatible with + // express-session's types await fastify.register(fastifySession, { secret: SESSION_SECRET, rolling: false, diff --git a/api/package.json b/api/package.json index a931bb106df..d7c025c5266 100644 --- a/api/package.json +++ b/api/package.json @@ -18,10 +18,11 @@ "description": "The freeCodeCamp.org open-source codebase and curriculum", "devDependencies": { "@fastify/type-provider-typebox": "2.4.0", + "@types/express-session": "1.17.7", "@types/supertest": "2.0.12", "jest": "29.5.0", - "prisma": "4.11.0", "pino-pretty": "10.0.0", + "prisma": "4.11.0", "supertest": "6.3.3", "ts-jest": "29.0.5" }, diff --git a/api/tsconfig.json b/api/tsconfig.json index adfcc0f8660..10dcdad3a1f 100644 --- a/api/tsconfig.json +++ b/api/tsconfig.json @@ -6,7 +6,6 @@ "strict": true, "forceConsistentCasingInFileNames": true, "esModuleInterop": true, - "resolveJsonModule": true, - "typeRoots": ["../node_modules/@types", "../node_modules/@fastify"] + "resolveJsonModule": true } } diff --git a/package.json b/package.json index 8d364b1d3c9..a125ab84c39 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "lint": "npm-run-all create:* -p lint:*", "lint:challenges": "cd ./curriculum && pnpm run lint", "lint:js": "eslint --max-warnings 0 .", - "lint:ts": "tsc && tsc -p config && tsc -p tools/ui-components && tsc -p utils", + "lint:ts": "tsc && tsc -p config && tsc -p tools/ui-components && tsc -p utils && tsc -p api", "lint:prettier": "prettier --list-different .", "reload:server": "pm2 reload api-server/ecosystem.config.js", "seed": "cross-env DEBUG=fcc:* node ./tools/scripts/seed/seed-demo-user", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4729fcc2b3f..96301c6208a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -119,6 +119,7 @@ importers: '@fastify/type-provider-typebox': 2.4.0 '@prisma/client': 4.11.0 '@sinclair/typebox': 0.25.24 + '@types/express-session': 1.17.7 '@types/supertest': 2.0.12 connect-mongo: 4.6.0 fastify: 4.14.1 @@ -143,6 +144,7 @@ importers: nodemon: 2.0.21 devDependencies: '@fastify/type-provider-typebox': 2.4.0_naatsb2dmwxq3j32xoqzjtyzqm + '@types/express-session': 1.17.7 '@types/supertest': 2.0.12 jest: 29.5.0 pino-pretty: 10.0.0 @@ -9265,6 +9267,12 @@ packages: '@types/qs': 6.9.7 '@types/range-parser': 1.2.4 + /@types/express-session/1.17.7: + resolution: {integrity: sha512-L25080PBYoRLu472HY/HNCxaXY8AaGgqGC8/p/8+BYMhG0RDOLQ1wpXOpAzr4Gi5TGozTKyJv5BVODM5UNyVMw==} + dependencies: + '@types/express': 4.17.17 + dev: true + /@types/express/4.17.17: resolution: {integrity: sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==} dependencies: