Allow RegExp literal argument
Opened this issue · 1 comments
codpro2005 commented
Like this:
const res = typedRegExp(/myPattern/);codpro2005 commented
This is a current TypeScript limitation as RegExp literals can't be const asserted, assumingly because they become class instances which by design are mutable:
const pattern = /myPattern/.source
// ?^ stringConsidering that RegExp.prototype.compile is deprecated now and the only way to mutate the source and flags properties, given that they are marked as readonly, potentially consider making a TypeScript issue to allow this as an exception.
Edit: An issue suggesting this for RegExp literal flags already exists here.