Closed smithki closed 1 year ago
Unfortunately, there's not a surefire way to type a replacer as it's not statically analyzable. Instead of passing all arguments to the ToCallback function, it would be more sound (in my opinion), to do something like this:
contents.replace(item, (...args) => replacement(args[0], args.pop()));
I believe this was incorrectly closed. Whatever method was believed to have completed this PR, still doesn't satisfy all the possibilities.
The
ToCallback
type definition indicates the second argument should bestring
, but actually the function takes the same shape as aString.prototype.replace
replacer.Unfortunately, there's not a surefire way to type a replacer as it's not statically analyzable. Instead of passing all arguments to the
ToCallback
function, it would be more sound (in my opinion), to do something like this: