| 17 | } |
| 18 | |
| 19 | export interface Regex< |
| 20 | out pattern extends string = string, |
| 21 | // @ts-ignore (override variance) |
| 22 | out ctx extends RegexContext = RegexContext |
| 23 | > extends RegExp { |
| 24 | [inferred]: pattern |
| 25 | infer: pattern |
| 26 | inferCaptures: ctx["captures"] extends IndexedCaptures ? ctx["captures"] : [] |
| 27 | inferNamedCaptures: ctx["names"] extends NamedCaptures ? ctx["names"] : {} |
| 28 | inferExecArray: RegexExecArray< |
| 29 | [pattern, ...this["inferCaptures"]], |
| 30 | this["inferNamedCaptures"], |
| 31 | this["flags"] |
| 32 | > |
| 33 | |
| 34 | flags: ctx["flags"] extends Flags ? ctx["flags"] : "" |
| 35 | |
| 36 | test(s: string): s is pattern |
| 37 | |
| 38 | exec(s: string): this["inferExecArray"] | null |
| 39 | // allow extension of base RegExp with more accurate types |
| 40 | // since parameters are identical, this overload will never be hit |
| 41 | exec(s: string): never |
| 42 | } |
| 43 | |
| 44 | export interface RegexParser { |
| 45 | <src extends string, flags extends Flags = "">( |
no outgoing calls
no test coverage detected
searching dependent graphs…