fix(ts): Align routerOptions defaultRoute types with runtime#6392
fix(ts): Align routerOptions defaultRoute types with runtime#6392Eomm merged 15 commits intofastify:mainfrom
Conversation
|
@Eomm @gurgunday |
No, there was an internal discussion regarding this PR and we were thinking if we should use the find-my-way's types instead. So waiting here some other review from the core team |
|
Just to be sure, should Fastify expose the full |
The whole Lines 97 to 99 in 012c249 |
Eomm
left a comment
There was a problem hiding this comment.
Last suggestion, then LGTM and it seems a real fix not targetting ts only!
|
I have added a regression test in test/router-options.test.js to confirm that extra I have also verified that the full test suite and benchmarks pass locally. |
|
@Eomm is there any problem related to the quality of code of this pr according to fastify? |
lib/error-serializer.js
Outdated
| const { | ||
| asString, | ||
| asNumber, | ||
| asBoolean, | ||
| asDateTime, | ||
| asDate, | ||
| asTime, | ||
| asUnsafeString | ||
| } = serializer | ||
|
|
||
| const asInteger = serializer.asInteger.bind(serializer) | ||
|
|
There was a problem hiding this comment.
Why does the diff show these?
There was a problem hiding this comment.
Can you rebase properly so we only see your changes?
|
Merged Linting issue not related to this PR |
Summary
Fixes #6389.
What was broken
routerOptions.defaultRouteandrouterOptions.onBadUrlwere typed as receivingFastifyReply, but the runtime always provides the raw NodeServerResponse. Consumers relying on the typedFastifyReplyhelpers (for examplereply.send) hit runtime errors despite the compiler reporting everything as safe.What this PR changes
RawRequestDefaultExpression/RawReplyDefaultExpression, so the compiler finally describes what the runtime actually hands youdocs/Reference/Server.mdthat these hooks get rawIncomingMessage/ServerResponseobjects, setting expectations for folks writing plain JavaScript tootest/types/instance.test-d.tssorouterOptionscan’t quietly drift back to exposingFastifyReplyTesting evidence
npm run lint→ passes (eslint only)npm run unit→ passes (borp, 2,140 tests run, 0 failures, 4 skips)npm run test:typescript→ passes (tsc + tsd)npm run benchmark --if-present→ passes (autocannon ~119k req/s avg, 672 MB read over 30 s)Checklist
npm run test && npm run benchmark --if-presentand the Code of conduct