Skip to content

Add createRegularExpressionLiteral and expose createStringLiteral#24000

Merged
mhegazy merged 1 commit into
microsoft:masterfrom
ajafff:regex-factory
May 10, 2018
Merged

Add createRegularExpressionLiteral and expose createStringLiteral#24000
mhegazy merged 1 commit into
microsoft:masterfrom
ajafff:regex-factory

Conversation

@ajafff
Copy link
Copy Markdown
Contributor

@ajafff ajafff commented May 9, 2018

Fixes: #23992

I also wanted to add it to the convenience function createLiteral:

if (value instanceof RegExp) {
    return createRegularExpressionLiteral(`/${value.source}/${value.flags}`);
}

Unfortunately that's not possible because RegExp#flags was introduced in ES2015.

Is there a reason the TypeScript compiler doesn't use lib: ["ES2015"]? It already declares ES2015 interfaces like Map and Iterator.

Comment thread src/compiler/factory.ts
return node;
}

export function createRegularExpressionLiteral(text: string): RegularExpressionLiteral {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 no need to add unit test for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are no unit tests for the other factory functions

@mhegazy mhegazy merged commit 3e08c41 into microsoft:master May 10, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants