Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input regexp #2

Closed
wants to merge 3 commits into from
Closed

Conversation

bluelovers
Copy link
Contributor

i didn't test

Copy link
Owner

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

Thank you for this PR.

However, this has a compile error.
Would you fix it?

src/index.ts Outdated
options?: RegExpParser.Options,
): AST.RegExpLiteral {
return new RegExpParser(options).parseLiteral(source)
return new RegExpParser(options).parseLiteral(source instanceof RegExp ? `/${source.source}/${source.flags}` : source)
Copy link
Owner

Choose a reason for hiding this comment

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

`/${source.source}/${source.flags}`

This is exact what RegExp#toString() does. I think you can use String(source) merely.

src/index.ts Outdated
export function parseRegExpLiteral(
source: string,
export function parseRegExpLiteral<T>(
source: T extends RegExp ? RegExp : string,
Copy link
Owner

Choose a reason for hiding this comment

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

I think that <T> is redundant. You can use source: string | RegExp,.

mysticatea added a commit that referenced this pull request Jun 16, 2018
bluelovers added a commit to bluelovers/regexpp that referenced this pull request May 7, 2019
* mysticatea/master:
  2.0.1
  Fix: follow tc39/ecma262#910 (refs eslint/eslint#10861)
  2.0.0
  2.0.0-beta.0
  Update: Unicode version to 11
  Breaking: replace Disjunction node by Alternative node
  Docs: update README.md
  Chore: trivial
  Chore: follow up mysticatea#2
  Update: parseRegExpLiteral supports RegExp object
  Chore: coverage
  Chore: upgrade deps
  Fix: location of quantifier (fixes mysticatea#3)
  New: add visitor
  Chore: update eslint config
  Breaking: drop Node.js 4 support

# Conflicts:
#	.eslintignore
#	.eslintrc.yml
#	package.json
#	src/index.ts
#	src/parser.ts
#	test/fixtures/parser/literal.ts
#	tsconfig.json
ota-meshi pushed a commit to ota-meshi/regexpp that referenced this pull request Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants