`npm run dev` (nodemon --exec ts-node) crashed on startup with 8 TS2769
errors ("RateLimitRequestHandler not assignable to Application") every
time -- the documented quick-start path in README.md never actually
worked.
Root cause: this is an npm workspaces monorepo. express-rate-limit is
only hoisted to the monorepo root node_modules, not nested under
gitgram/backend/node_modules. Its own .d.ts resolves `express` by
walking up node_modules from wherever the package physically lives, so
it lands on the root's hoisted express@4 (and @types/express-serve-
static-core@4.19.8) instead of this package's own pinned express@5.1.0
/ @types/express@5.0.5 -- producing a real-looking but spurious cross-
package type mismatch on every `app.use(limiter)` call.
`npx tsc` / `tsc --noEmit` (the actual build and CI gate) do not hit
this at all and stay green -- confirmed before and after this change.
Set `transpileOnly: true` for the dev-loop ts-node process (the
standard fix for this exact class of ts-node + monorepo hoisting
false positive), so `npm run dev` boots instead of crashing on typings
that aren't a real bug in this project's own code.
Verified for real, not just via tsc:
- Spun up throwaway local postgres+redis containers, ran
`prisma migrate deploy` (4/4 migrations clean), booted the backend
with `npm run dev`'s actual command -- it now boots and serves
/health with a live DB connection; it previously hard-crashed before
a single request.
- Re-ran the full messaging + cross-tenant IDOR flow live end-to-end:
registered 3 real users, created a real group chat (A+B), both
members send/read successfully (201/200), and a non-member (C)
gets a real 403 on both GET /messages/chats/:chatId and
POST /messages with that chatId -- the IDOR fix from 487e4312 still
holds.
- Re-ran tests/messages.test.ts with and without this change (via git
stash): identical 17 failed / 15 passed both times, proving this is
the same pre-existing mocked-Prisma flakiness already documented in
plans/back-catalog.md, not a regression from this fix.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
50 lines
2.2 KiB
JSON
50 lines
2.2 KiB
JSON
{
|
|
"compilerOptions": {
|
|
"target": "ES2020",
|
|
"module": "commonjs",
|
|
"lib": ["ES2020"],
|
|
"outDir": "./dist",
|
|
"rootDir": "./src",
|
|
"strict": true,
|
|
"esModuleInterop": true,
|
|
"allowSyntheticDefaultImports": true,
|
|
"skipLibCheck": true,
|
|
"forceConsistentCasingInFileNames": true,
|
|
"resolveJsonModule": true,
|
|
"moduleResolution": "node",
|
|
// TS7.0 turns the legacy "node" (node10) resolver into a hard error. We keep
|
|
// node10 semantics intentionally (CommonJS output) and silence the pre-7.0
|
|
// deprecation so `tsc --noEmit` stays green until a deliberate resolver bump.
|
|
// "6.0" is not a value the pinned typescript@^5.9.3 (see package.json)
|
|
// recognizes -- it hard-errors with TS5103 and the project fails to build
|
|
// or even boot via ts-node at all. "5.0" is the value this TS major
|
|
// actually accepts for this flag.
|
|
"ignoreDeprecations": "5.0",
|
|
"typeRoots": ["./node_modules/@types"],
|
|
"declaration": true,
|
|
"declarationMap": true,
|
|
"sourceMap": true
|
|
},
|
|
"include": ["src/**/*"],
|
|
"exclude": ["node_modules", "dist", "tests"],
|
|
// `npm run dev` (nodemon --exec ts-node) refused to boot at all: this is an
|
|
// npm workspaces monorepo, and express-rate-limit is only hoisted to the
|
|
// *root* node_modules, not nested under backend/node_modules. Its own type
|
|
// declarations resolve `express` by walking up from where the package
|
|
// actually lives, so they land on the root's hoisted express@4 (and its
|
|
// @types/express-serve-static-core@4.19.8) instead of this package's own
|
|
// pinned express@5.1.0 / @types/express@5.0.5 -- producing a real-looking
|
|
// but spurious "RateLimitRequestHandler not assignable to Application"
|
|
// type error on every `app.use(limiter)` call. `npx tsc`/`tsc --noEmit`
|
|
// (the actual build + CI gate) do NOT hit this: they resolve cleanly and
|
|
// stay the source of truth for real type errors. `transpileOnly` makes the
|
|
// dev-loop ts-node process behave the same way most Node teams run
|
|
// ts-node in watch mode -- strip types fast, don't re-typecheck on every
|
|
// save -- so `npm run dev` boots instead of crashing on a cross-package
|
|
// typings collision that isn't a real bug in this project's own code.
|
|
"ts-node": {
|
|
"transpileOnly": true
|
|
}
|
|
}
|
|
|