0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/server-adapters/express/examples
mastra-platform[bot] 290874e141
fix(server-adapters): make tsc -p pass for every server adapter (#28219)
> Opened by @abhiaiyer91

## Summary
Running `tsc -p server-adapters/<adapter>/tsconfig.json` fails on `main`
for several adapters. Review gates that typecheck adapter packages fail
because of it.

**express, fastify, elysia:** each `examples/index.ts` destructures
`getInitData()` without a type argument. That call returns `unknown`, so
TS2339 fires. The fix passes a type argument, the same way
`server-adapters/hono/examples/index.ts` already does:
- `getInitData<typeof weatherWorkflow>()` for `city`
- `getInitData<{ vacationDescription: string }>()` for the travel
planner step. An inline type avoids a self-referential `typeof
travelAgentWorkflow`.

koa had the same error, but main fixed it in #28207. This PR takes
main's version and no longer changes koa.

**nestjs:** `tsdown.config.ts` set an `esbuildOptions` hook to force the
decorator compiler flags. The installed tsdown (0.23.1) builds with
rolldown and has no `esbuildOptions` option, so the hook never ran
during the build, and tsc rejects it (TS2769, TS7006). The decorator
flags already reach the build another way: `tsconfig.json` sets
`experimentalDecorators` and `emitDecoratorMetadata`, and tsdown passes
the tsconfig to rolldown. The fix deletes the dead hook and adds
`tsconfig: 'tsconfig.json'` so the source of those flags is explicit.

No `src/` or tsconfig changes, no ts-ignore, `any` or casts.

**No changeset, on purpose.** This PR only changes `examples/` and build
config, and no published output changes. Per the maintainer, it doesn't
get a changeset. The changeset gate check is expected to flag it.

## Proof
**tsc:** `npx tsc -p tsconfig.json --noEmit` from each adapter directory
(error counts). The After column is on head 3a5ef138, which has
origin/main 4d7ecb26 merged in.

| Adapter | Before (origin/main d7c7aedc) | After |
|---|---|---|
| hono | 0 | 0 |
| express | 2 (`examples/index.ts:206`, `:339`) | 0 |
| fastify | 1 (`examples/index.ts:217`) | 0 |
| koa | 1 (`examples/index.ts:202`), fixed on main by #28207 | 0 |
| elysia | 2 (`examples/index.ts:230`, `:378`) | 0 |
| nestjs | 2 (`tsdown.config.ts:13`, TS2769 and TS7006) | 0 |
| next | 0 | 0 |
| tanstack-start | 0 | 0 |

**nestjs dist:** I ran `pnpm build` in `server-adapters/nestjs` before
and after the config change. `diff -rq` across all 24 dist files (ESM,
CJS, `.d.ts` and sourcemaps) found no differences. The decorator
metadata output (`__decorateMetadata` / `design:paramtypes`) is present
in both builds.

**nestjs tests (`pnpm test`):** the same result before and after:
2838/2838 tests pass, and 16 of 19 test files pass. The other 3 files
(`auth-guard-export`, `malformed-json`, `mastra-module`) already fail on
main: vitest hits a parse error loading them and runs no tests from
them. vitest doesn't read `tsdown.config.ts`, so this PR can't affect
them.

**Lint:** `oxlint` and `oxfmt --check` on the changed files: clean.

## Unverified
- I didn't run the example servers. The examples change is type-only, so
the emitted JS is identical.
- I didn't fix or investigate the 3 nestjs test files that fail to load
on main.
- After the merge with main, I didn't rebuild nestjs or re-run its
tests. The merge didn't touch `tsdown.config.ts`.

Risk: low

---------

Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
History 2026-10-22 21:38:49 -04:00
..
index.ts fix(server-adapters): make tsc -p pass for every server adapter (#28219) 2026-10-22 21:38:49 -04:00