Open RAnders00 opened 5 years ago
I had this idea before, too. But this will not play nicely with minifiers. They'll mangle your function names and your run time and compile time values will be different.
So, it'll work okay for specific cases but not in general.
You can, of course, preserve your function names after minification by disabling the option to mangle function names, or using Object.defineProperty()
Also, in some environments, I think the name is always an empty string, no matter what. I can't remember if my memory is hazy or if it is actually true. I couldn't find anything after a minute of Google. I'm going to assume my memory is bad
Regarding minifiers,
Search Terms
ES6 function name, const assertions,
as const
, function as constSuggestion
I would like to see the
name
property of functions to be available at compile time if the given function is aconst
expression, e.g.:Use Cases
My use case is a function like shown above, where I would like to have static type checking available, without having to specify the extra parameter that specifies the function name to replace, e.g. compare:
Examples
Checklist
My suggestion meets these guidelines: