Skip to content

Commit

Permalink
fix: update '@agoric/assert' types
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Feb 12, 2021
1 parent 9309dd9 commit 3ce7587
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/assert/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,28 @@
* @returns {StringablePayload} The declassified payload
*/

/**
* @typedef {(template: TemplateStringsArray | string[], ...args: any) => DetailsToken} DetailsTag
*
* Use the `details` function as a template literal tag to create
* informative error messages. The assertion functions take such messages
* as optional arguments:
* ```js
* assert(sky.isBlue(), details`${sky.color} should be "blue"`);
* ```
* The details template tag returns a `DetailsToken` object that can print
* itself with the formatted message in two ways.
* It will report the real details to
* the console but include only the typeof information in the thrown error
* to prevent revealing secrets up the exceptional path. In the example
* above, the thrown error may reveal only that `sky.color` is a string,
* whereas the same diagnostic printed to the console reveals that the
* sky was green.
*
* The `raw` member of a `template` is ignored, so a simple
* `string[]` can also be used as a template.
*/

/**
* assert that expr is truthy, with an optional details to describe
* the assertion. It is a tagged template literal like
Expand Down

0 comments on commit 3ce7587

Please sign in to comment.