diff --git a/cli/tests/unit/urlpattern_test.ts b/cli/tests/unit/urlpattern_test.ts index 9bed092355..cb5fc76c53 100644 --- a/cli/tests/unit/urlpattern_test.ts +++ b/cli/tests/unit/urlpattern_test.ts @@ -1,5 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. import { assert, assertEquals } from "./test_util.ts"; +import { assertType, IsExact } from "../../../test_util/std/testing/types.ts"; Deno.test(function urlPatternFromString() { const pattern = new URLPattern("https://deno.land/foo/:bar"); @@ -13,6 +14,10 @@ Deno.test(function urlPatternFromString() { assert(match); assertEquals(match.pathname.input, "/foo/x"); assertEquals(match.pathname.groups, { bar: "x" }); + + // group values should be nullable + const val = match.pathname.groups.val; + assertType>(true); }); Deno.test(function urlPatternFromStringWithBase() { diff --git a/cli/tsc/dts/lib.dom.extras.d.ts b/cli/tsc/dts/lib.dom.extras.d.ts index 2c593b2cbe..9116596a6a 100644 --- a/cli/tsc/dts/lib.dom.extras.d.ts +++ b/cli/tsc/dts/lib.dom.extras.d.ts @@ -23,7 +23,7 @@ declare type URLPatternInput = string | URLPatternInit; declare interface URLPatternComponentResult { input: string; - groups: Record; + groups: Record; } /** `URLPatternResult` is the object returned from `URLPattern.exec`. */ diff --git a/ext/url/lib.deno_url.d.ts b/ext/url/lib.deno_url.d.ts index 1d5f840199..9a8c155d99 100644 --- a/ext/url/lib.deno_url.d.ts +++ b/ext/url/lib.deno_url.d.ts @@ -206,7 +206,7 @@ declare type URLPatternInput = string | URLPatternInit; /** @category Web APIs */ declare interface URLPatternComponentResult { input: string; - groups: Record; + groups: Record; } /** `URLPatternResult` is the object returned from `URLPattern.exec`.