Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export namespace CommonNames {
export const I31ref = "I31ref";
export const Dataref = "Dataref";
export const String = "String";
export const RegExp = "RegExp";
export const Object = "Object";
export const Array = "Array";
export const StaticArray = "StaticArray";
Expand Down
8 changes: 8 additions & 0 deletions src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,14 @@ export class Program extends DiagnosticEmitter {
}
private _stringInstance: Class | null = null;

/** Gets the standard `RegExp` instance. */
get regexpInstance(): Class {
var cached = this._regexpInstance;
if (!cached) this._regexpInstance = cached = this.requireClass(CommonNames.RegExp);
return cached;
}
private _regexpInstance: Class | null = null;

/** Gets the standard `Object` instance. */
get objectInstance(): Class {
var cached = this._objectInstance;
Expand Down
3 changes: 3 additions & 0 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,9 @@ export class Resolver extends DiagnosticEmitter {
case LiteralKind.TEMPLATE: {
return this.program.stringInstance;
}
case LiteralKind.REGEXP: {
return this.program.regexpInstance;
}
case LiteralKind.ARRAY: {
let classReference = ctxType.getClass();
if (classReference && classReference.prototype == this.program.arrayPrototype) {
Expand Down
7 changes: 7 additions & 0 deletions tests/compiler/indexing-regexp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"asc_flags": [
],
"stderr": [
"TS2329: Index signature is missing in type '~lib/regexp/RegExp'"
]
}
1 change: 1 addition & 0 deletions tests/compiler/indexing-regexp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/ /[0];
7 changes: 7 additions & 0 deletions tests/compiler/typeof-regexp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"asc_flags": [
],
"stderr": [
"AS100: Not implemented: Regular expressions"
]
}
1 change: 1 addition & 0 deletions tests/compiler/typeof-regexp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
typeof / /;