Fix TypeScript type narrowing issue with isUrlString

Fixes #212
This commit is contained in:
Sindre Sorhus 2025-09-12 03:58:08 +07:00
parent ef35cc350a
commit c68ad76062
3 changed files with 33 additions and 3 deletions

View file

@ -75,3 +75,10 @@ export type Predicate = (value: unknown) => boolean;
export type NonEmptyString = string & {0: string};
export type Whitespace = ' ';
/**
A string that represents a valid URL.
This is a branded type to prevent incorrect TypeScript type narrowing.
*/
export type UrlString = string & {readonly __brand: 'UrlString'};