Skip to content

docs: preserve CIDR tuple types in subnetMatch example - #215

Merged
whitequark merged 1 commit into
whitequark:mainfrom
merak-max:docs/typescript-subnet-example
Sep 27, 2026
Merged

whitequark merged 1 commit into
whitequark:mainfrom
merak-max:docs/typescript-subnet-example

Conversation

@merak-max

Copy link
Copy Markdown
Contributor

Use parseCIDR() in the named-range README example so its inferred types work in both JavaScript and TypeScript. Add a short explanation of why separately declared array literals lose tuple inference.

This applies the solution already suggested by @Manouchehri in #170 to the current documentation; no runtime or declaration changes.

Validation:

  • Reproduced TS2345 with the current array-literal example using TypeScript 5.9 in strict NodeNext mode.
  • The revised example type-checks with the same settings.
  • npm test: all 70 tests pass.

I encountered this while using ipaddr.js in a TypeScript webhook inspection tool. This documentation patch was prepared with AI assistance and checked with the commands above.

@whitequark
whitequark merged commit b70b039 into whitequark:main Sep 27, 2026
2 checks passed
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.

2 participants