We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug I'm using XRegExp to build complex / nested regular expressions. I'm investigating using ts-macros for this purpose.
XRegExp
ts-macros
Code to reproduce
import * as XRegExp from 'xregexp' const $buildFragments = (rawFragments: string[][]) => { const fragments: Record<string, RegExp> = {} rawFragments.forEach(fragment => { fragments[fragment[0]] = XRegExp.build(fragment[1], fragments) }) return fragments } const fragments: Record<string, RegExp> = $buildFragments!(rawFragments)
(Fragments are regex strings like:)
const fragments = () => [ ['newline', '\\n|\\r\\n?|\\f'], ['whitespace', '[ ]|\\t|{{newline}}'], ['ws', '{{whitespace}}+'], ['comment', '\\/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*\\/'], ['hex', '[\\da-fA-F]'], ['unicode', '\\\\{{hex}}{1,6}{{whitespace}}?'] ]
Expected behavior I expected a static object to be output with a map of regular expressions.
Additional context Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Thanks for the bug report! You can only define macros with the function keyword, the code below works correctly:
function
function $buildFragments(rawFragments: string[][]) { const fragments: Record<string, RegExp> = {} rawFragments.forEach(fragment => { fragments[fragment[0]] = XRegExp.build(fragment[1], fragments) }) return fragments }
However there's definitely something wrong going on if you try to declare it as an arrow function, I'll look into it!
Sorry, something went wrong.
@GoogleFeud Ohhhh ha, I didn't think of that, thanks!
f6a3aaf
No branches or pull requests
Describe the bug
I'm using
XRegExp
to build complex / nested regular expressions. I'm investigating usingts-macros
for this purpose.Code to reproduce
(Fragments are regex strings like:)
Expected behavior
I expected a static object to be output with a map of regular expressions.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: