import { Regex, RegexParser, regex } from "../node_modules/.pnpm/arkregex@0.0.8_patch_hash_3f67bd7e43eee25c719bf062c781074cdc10fd2636c0bfe0e1d332a7d32f7dcd/node_modules/arkregex/out/regex.mjs"; //#region src/regex/regex-typed.d.ts type RegexFlags = NonNullable[1]>; /** * A typed drop-in for `new RegExp()`. At runtime it is exactly * `new RegExp(source, flags)`; all of its value is in the types — the source is * parsed at the type level to infer the matched string, positional captures and * named captures, and `.test()` narrows its argument to the inferred pattern. * * Invalid patterns (e.g. referencing a group that does not exist) become type * errors instead of failing at runtime. * * Companion type-level helpers are available on the same symbol: * - `regexTyped.infer` — the inferred pattern type, without constructing anything. * - `regexTyped.validate` — the validated source, or an error message type. * - `regexTyped.parse` — the full parse result. * * The source must be a string *literal* — inference relies on the literal type, * so a dynamically built (widened `string`) source is rejected at the type level. * For a pattern too long or complex for TypeScript to infer, manually type it * with `regexTyped.as(source, flags)`. * * Note: with the `g` or `y` flag, the returned `RegExp` is stateful — `.test()` * and `.exec()` advance `lastIndex` between calls, exactly like a native `RegExp`. * @example * const ok = regexTyped('^ok$', 'i'); * // Regex<'ok' | 'oK' | 'Ok' | 'OK', {flags: 'i'}> * @example * const semver = regexTyped('^(\\d+)\\.(\\d+)\\.(\\d+)$'); * // captures inferred as [`${number}`, `${number}`, `${number}`] * @example * const email = regexTyped('^(?\\w+)@(?\\w+\\.\\w+)$'); * // named captures inferred as {name: string; domain: `${string}.${string}`} * @example * // Escape hatch for patterns too complex to infer: * const complex = regexTyped.as<`id-${string}`, {captures: [string]}>('id-(.+)'); */ declare const regexTyped: RegexParser; declare namespace regexTyped { type infer = regex.infer; type validate = regex.validate; type parse = regex.parse; } //#endregion export { type Regex as RegexTyped, regexTyped };