Skip to content

Commit df63d60

Browse files
authored
Support regexp literal (#346)
1 parent 279b96c commit df63d60

File tree

3 files changed

+100
-85
lines changed

3 files changed

+100
-85
lines changed

src/source.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export class Source {
6767

6868
switch (type) {
6969
case 'NumericLiteral':
70-
case 'StringLiteral': {
70+
case 'StringLiteral':
71+
case 'RegExpLiteral': {
7172
const raw = this.text.slice(node.start, node.end);
7273
const { value } = node as unknown as
7374
| babel.NumericLiteral

src/transform-node.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,18 @@ class Transformer extends Source {
384384
}
385385
}
386386

387+
if (node instanceof angular.RegularExpressionLiteral) {
388+
return this.#create<babel.RegExpLiteral>(
389+
{
390+
type: 'RegExpLiteral',
391+
pattern: node.body,
392+
flags: node.flags ?? '',
393+
...node.sourceSpan,
394+
},
395+
{ hasParentParens: isInParentParens },
396+
);
397+
}
398+
387399
if (node instanceof angular.Call || node instanceof angular.SafeCall) {
388400
const isOptionalType = node instanceof angular.SafeCall;
389401
const { receiver, args } = node;

0 commit comments

Comments
 (0)