mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 16:19:12 -05:00
fix(dts): URLPatternComponentResult
groups should have possibly undefined key values (#18643)
Closes #18640
This commit is contained in:
parent
e2761df3fe
commit
f4e442da4d
3 changed files with 7 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, assertEquals } from "./test_util.ts";
|
import { assert, assertEquals } from "./test_util.ts";
|
||||||
|
import { assertType, IsExact } from "../../../test_util/std/testing/types.ts";
|
||||||
|
|
||||||
Deno.test(function urlPatternFromString() {
|
Deno.test(function urlPatternFromString() {
|
||||||
const pattern = new URLPattern("https://deno.land/foo/:bar");
|
const pattern = new URLPattern("https://deno.land/foo/:bar");
|
||||||
|
@ -13,6 +14,10 @@ Deno.test(function urlPatternFromString() {
|
||||||
assert(match);
|
assert(match);
|
||||||
assertEquals(match.pathname.input, "/foo/x");
|
assertEquals(match.pathname.input, "/foo/x");
|
||||||
assertEquals(match.pathname.groups, { bar: "x" });
|
assertEquals(match.pathname.groups, { bar: "x" });
|
||||||
|
|
||||||
|
// group values should be nullable
|
||||||
|
const val = match.pathname.groups.val;
|
||||||
|
assertType<IsExact<typeof val, string | undefined>>(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test(function urlPatternFromStringWithBase() {
|
Deno.test(function urlPatternFromStringWithBase() {
|
||||||
|
|
2
cli/tsc/dts/lib.dom.extras.d.ts
vendored
2
cli/tsc/dts/lib.dom.extras.d.ts
vendored
|
@ -23,7 +23,7 @@ declare type URLPatternInput = string | URLPatternInit;
|
||||||
|
|
||||||
declare interface URLPatternComponentResult {
|
declare interface URLPatternComponentResult {
|
||||||
input: string;
|
input: string;
|
||||||
groups: Record<string, string>;
|
groups: Record<string, string | undefined>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** `URLPatternResult` is the object returned from `URLPattern.exec`. */
|
/** `URLPatternResult` is the object returned from `URLPattern.exec`. */
|
||||||
|
|
2
ext/url/lib.deno_url.d.ts
vendored
2
ext/url/lib.deno_url.d.ts
vendored
|
@ -206,7 +206,7 @@ declare type URLPatternInput = string | URLPatternInit;
|
||||||
/** @category Web APIs */
|
/** @category Web APIs */
|
||||||
declare interface URLPatternComponentResult {
|
declare interface URLPatternComponentResult {
|
||||||
input: string;
|
input: string;
|
||||||
groups: Record<string, string>;
|
groups: Record<string, string | undefined>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** `URLPatternResult` is the object returned from `URLPattern.exec`.
|
/** `URLPatternResult` is the object returned from `URLPattern.exec`.
|
||||||
|
|
Loading…
Reference in a new issue