I have a bunch of these in a module separate from my execution code:
const warnings = {
functionDoesNotReturnValue: {
message: `${name} did not return a value`,
get: (name) => {
return {
action: warnings.functionDoesNotReturnValue.action,
message: `'${name}' did not return a value`,
};
},
},
I currently have the get
method added, which just provides the interpolation string required and applies it to a copy of message
within the function.
But I would like to remove the redundant get
function entirely and supply the provided name
parameter directly to the message
property as required, since every warning currently needs its own redundant get method, which simply contains copy of the message
property and returns the interpolated version, purely so that execution of the string template may be deferred until the time get
is run.
I can't figure out how to do this via tag methods: whatever happens, the template string appears to evaluate the as soon as the program is run. Any suggestions on a more elegant way to handle this?