-
-
Notifications
You must be signed in to change notification settings - Fork 880
Closed
Labels
Description
I was logging a lot of things to stderr in my TypeScript project, so I wanted to create a neat wrapper for this:
function log (text: TemplateStringsArray, ...placeholders: unknown[]): void {
console.error(chalk.stderr(text, ...placeholders))
}
Unfortunately, this yielded the following error:
TypeError: chalk.apply is not a function
at log (/foo/bar.ts:2:22)
I hadn't yet setup a tsconfig
, so my project was targeting ES5. This meant that the ...placeholders
call was converted to use .apply
, which is assumed to exist on every function.
However, since chalk changes the prototype of the function, there is no longer any apply
, call
or other things from the Function
prototype.
I think that this could be easily resolved by adding in apply
, call
, etc. manually. But I wanted to open this to get some feedback first.