Use as a template literal tag to create and throw an error in whose
message unquoted substitution values (i.e., those that are not output
from the quote function) may have been redacted into lossy typeof
output but are still available for logging to an associated console.
For example, using the normal convention to locally rename properties like
const { quote: q, Fail } = assert;:
sky.isBlue() || Fail`${sky.color} should be "blue"`;
This || pattern saves the cost of creating DetailsToken and/or
error instances when the asserted condition holds, but can weaken
TypeScript static reasoning due to
https://github.com/microsoft/TypeScript/issues/51426 . Where this is a
problem, instead express the assertion as
if (!sky.isBlue()) { // This `throw` does not affect runtime behavior since `Fail` throws, but // might be needed to improve static analysis. throwFail`${sky.color} should be "blue"`; }
The raw property of an input template array is ignored, so a simple
array of strings may be provided directly.
Use as a template literal tag to create and throw an error in whose
messageunquoted substitution values (i.e., those that are not output from the quote function) may have been redacted into lossytypeofoutput but are still available for logging to an associated console.For example, using the normal convention to locally rename properties like
const { quote: q, Fail } = assert;:This
||pattern saves the cost of creating DetailsToken and/or error instances when the asserted condition holds, but can weaken TypeScript static reasoning due to https://github.com/microsoft/TypeScript/issues/51426 . Where this is a problem, instead express the assertion asThe
rawproperty of an input template array is ignored, so a simple array of strings may be provided directly.