TypeScript says:
The property ' $1 ' does not exist with a value of the type ' { (pattern: string, flags?: string): RegExp; new(pattern: string, flags?: string): RegExp; } { (pattern: string, flags?: string): RegExp; new(pattern: string, flags?: string): RegExp; } { (pattern: string, flags?: string): RegExp; new(pattern: string, flags?: string): RegExp; } '
We explain the type by looking at the definition from lib.d.ts , which appeared using TypeScript 0.8.2:
interface RegExp { exec(string: string): RegExpExecArray; test(string: string): bool; source: string; global: bool; ignoreCase: bool; multiline: bool; lastIndex: number; } declare var RegExp: { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; }
My question is, how can I change / update this to allow me to reference RegExp.$1 , RegExp.$2 , etc.? It is preferable that I can declare separately, since I do not intend to directly edit lib.d.ts (which will most likely be replaced as it is updated)
I tried this to no avail:
declare var RegExp: { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; $1: any; $2: any; $3: any; $4: any; $5: any; $6: any; $7: any; $8: any; $9: any; }
I assume that they should be declared with type string . But in any case, it does not remove the error.
In addition to this, I also wonder what exactly this means (why is this declared with and without new ?):
new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp;