Skip to content

chore: set propert type in noSwap - #4112

Open
imaliouris wants to merge 1 commit into
bigskysoftware:fourfrom
imaliouris:patch-1
Open

imaliouris wants to merge 1 commit into
bigskysoftware:fourfrom
imaliouris:patch-1

Conversation

@imaliouris

Copy link
Copy Markdown

Description

htmx 4's docs show htmx.config.noSwap = [204, 304, '4xx', '5xx'] as the way to restore htmx 2.x error-swapping behavior (see the migration guide and "What's New in htmx 4"). In a TypeScript project this assignment produces a type error, because the shipped type definitions don't match htmx 4's config.

This PR updates the type definitions so that:

  • htmx.config.noSwap is typed as (number | string)[], so status codes and wildcard patterns like '4xx' and '5xx' are accepted

Example that previously failed to type-check and now compiles:

htmx.config.noSwap = [204, 304, '4xx', '5xx'];

Testing

  • Ran tsc --noEmit against a small TypeScript file containing the snippet above. It errored before this change and passes after.
  • Checked that numeric-only values such as htmx.config.noSwap = [204, 304] still type-check.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant