From e4e0f4d435a27619d58626438e2d9ba25993ab34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 17 Jul 2025 13:32:36 +0900 Subject: [PATCH 1/2] enhance(types): Narrow down type definition of subnetMatch --- lib/ipaddr.js.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ipaddr.js.d.ts b/lib/ipaddr.js.d.ts index 62afab3..ae9c2e7 100644 --- a/lib/ipaddr.js.d.ts +++ b/lib/ipaddr.js.d.ts @@ -22,7 +22,7 @@ declare module "ipaddr.js" { export function parse(addr: string): IPv4 | IPv6; export function parseCIDR(mask: string): [IPv4 | IPv6, number]; export function process(addr: string): IPv4 | IPv6; - export function subnetMatch(addr: IPv4 | IPv6, rangeList: RangeList, defaultName?: string): string; + export function subnetMatch, D extends string = "unicast">(addr: IPv4 | IPv6, rangeList: L, defaultName?: D): keyof L | D; export class IPv4 extends IP { static broadcastAddressFromCIDR(addr: string): IPv4; @@ -40,7 +40,7 @@ declare module "ipaddr.js" { kind(): 'ipv4'; match(what: IPv4 | IPv6 | [IPv4 | IPv6, number], bits?: number): boolean; range(): IPv4Range; - subnetMatch(rangeList: RangeList, defaultName?: string): string; + subnetMatch, D extends string = "unicast">(rangeList: RangeList, defaultName?: D): keyof L | D; toIPv4MappedAddress(): IPv6; } @@ -61,7 +61,7 @@ declare module "ipaddr.js" { kind(): 'ipv6'; match(what: IPv4 | IPv6 | [IPv4 | IPv6, number], bits?: number): boolean; range(): IPv6Range; - subnetMatch(rangeList: RangeList, defaultName?: string): string; + subnetMatch, D extends string = "unicast">(rangeList: L, defaultName?: D): keyof L | D; toIPv4Address(): IPv4; toRFC5952String(): string; } From 6c1dfc7c0eec43c1bcad612009991699113b8366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 17 Jul 2025 13:33:22 +0900 Subject: [PATCH 2/2] fix --- lib/ipaddr.js.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ipaddr.js.d.ts b/lib/ipaddr.js.d.ts index ae9c2e7..048c6e4 100644 --- a/lib/ipaddr.js.d.ts +++ b/lib/ipaddr.js.d.ts @@ -40,7 +40,7 @@ declare module "ipaddr.js" { kind(): 'ipv4'; match(what: IPv4 | IPv6 | [IPv4 | IPv6, number], bits?: number): boolean; range(): IPv4Range; - subnetMatch, D extends string = "unicast">(rangeList: RangeList, defaultName?: D): keyof L | D; + subnetMatch, D extends string = "unicast">(rangeList: L, defaultName?: D): keyof L | D; toIPv4MappedAddress(): IPv6; }