Skip to content

fix(types): allow explicit http2: false in server options - #6888

Merged
Eomm merged 1 commit into
fastify:mainfrom
Tony133:fix/types-http2-false-option
Aug 2, 2026
Merged

Eomm merged 1 commit into
fastify:mainfrom
Tony133:fix/types-http2-false-option

Conversation

@Tony133

@Tony133 Tony133 commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Proposal:

  • Adds an optional http2?: false property to FastifyHttpOptions andFastifyHttpsOptions so that explicitly passing http2: false no longer triggers a TypeScript error, matching the runtime behavior in lib/server.js which already falls back to http.createServer/https correctly when http2 is false.

  • Adds type tests verifying that fastify({ http2: false }) resolves to an http1 instance and fastify({ https: {}, http2: false }) resolves to an https instance, updated to the tstyche syntax used by the current test suite.

Closes #5682 and replaces this PR: #6585, which is no longer up to date since it still uses tsd for type testing

@github-actions github-actions Bot added the typescript TypeScript related label Jul 30, 2026
@Tony133
Tony133 marked this pull request as ready for review July 30, 2026 15:23
@Tony133
Tony133 requested a review from a team July 30, 2026 15:23
@Eomm Eomm added the bugfix Issue or PR that should land as semver patch label Aug 2, 2026
@Eomm
Eomm merged commit 0f54a40 into fastify:main Aug 2, 2026
40 checks passed
@Tony133
Tony133 deleted the fix/types-http2-false-option branch August 2, 2026 11:05
climba03003 pushed a commit that referenced this pull request Aug 4, 2026
* fix(types): allow explicit http2: false in server options (#6888)

* docs: clarify what attachValidation exposes on request.validationError (#6891)

* docs: clarify what attachValidation exposes on request.validationError

The docs described `request.validationError` as carrying "the raw
validation result", and the inline example pointed only at
`.validation`. That wording implied the descriptive message had to be
rebuilt by hand, which is what prompted #5235.

`wrapValidationError()` in lib/validation.js runs `schemaErrorFormatter`
and `validationCompleted()` in lib/handle-request.js assigns that same
error to `request.validationError`. There is no raw-only path, so
`.message` is identical to the message sent when `attachValidation` is
unset.

List the properties actually available (`message`, `validation`,
`validationContext`, `code`, `statusCode`) and add a test pinning the
equivalence between the attached and the default message.

* test: improve validation error message assertions in attached validation test

* refactor(types): remove deprecated FastifyPlugin type

Removed the deprecated FastifyPlugin type export and its corresponding test definitions. Users should use FastifyPluginAsync or FastifyPluginCallback instead.

* fix: update url

---------

Co-authored-by: Tiziano Basile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Issue or PR that should land as semver patch typescript TypeScript related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript types for http2

3 participants