Note that there are some explanatory texts on larger screens.

plurals
  1. POTypeScript and RegExp
    primarykey
    data
    text
    <p>TypeScript says: </p> <blockquote> <p>The property '<code>$1</code>' does not exist on value of type '<code>{ (pattern: string, flags?: string): RegExp; new(pattern: string, flags?: string): RegExp; }</code>'</p> </blockquote> <p>The type is explainable by looking at the definition from <code>lib.d.ts</code> that came with <em>TypeScript 0.8.2</em>: </p> <pre><code>interface RegExp { /** * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. * @param string The String object or string literal on which to perform the search. */ exec(string: string): RegExpExecArray; /** * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. * @param string String on which to perform the search. */ test(string: string): bool; /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ source: string; /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ global: bool; /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ ignoreCase: bool; /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ multiline: bool; lastIndex: number; } declare var RegExp: { new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; } </code></pre> <p>My question is how can I change/update this to allow me to reference <code>RegExp.$1</code>, <code>RegExp.$2</code>, etc.? Preferably something I can declare separately since I do not intend to directly edit <code>lib.d.ts</code> (which will most likely get replaced as it is updated)</p> <p>I tried this to no avail: </p> <pre><code>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; } </code></pre> <p>I guess they should be declared with type <code>string</code> actually. But in any case it doesn't remove the errors. </p> <p>In addition to this I'm also curious about what this means exactly (why is it declared with and without a <code>new</code>?): </p> <pre><code>new (pattern: string, flags?: string): RegExp; (pattern: string, flags?: string): RegExp; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload