| 72 | } |
| 73 | |
| 74 | export interface Regex< |
| 75 | out pattern extends string = string, |
| 76 | // @ts-ignore (override variance) |
| 77 | out ctx extends RegexContext = RegexContext |
| 78 | > extends RegExp { |
| 79 | [inferred]: pattern |
| 80 | infer: pattern |
| 81 | inferCaptures: ctx["captures"] extends IndexedCaptures ? ctx["captures"] : [] |
| 82 | inferNamedCaptures: ctx["names"] extends NamedCaptures ? ctx["names"] : {} |
| 83 | inferExecArray: RegexExecArray< |
| 84 | [pattern, ...this["inferCaptures"]], |
| 85 | this["inferNamedCaptures"], |
| 86 | this["flags"] |
| 87 | > |
| 88 | |
| 89 | flags: ctx["flags"] extends Flags ? ctx["flags"] : "" |
| 90 | |
| 91 | test(s: string): s is pattern |
| 92 | |
| 93 | exec(s: string): this["inferExecArray"] | null |
| 94 | // allow extension of base RegExp with more accurate types |
| 95 | // since parameters are identical, this overload will never be hit |
| 96 | exec(s: string): never |
| 97 | } |
| 98 | |
| 99 | export interface RegexParser { |
| 100 | <src extends string, flags extends string = "">( |
no outgoing calls
no test coverage detected