diff options
| author | binarycat <binarycat@envs.net> | 2025-03-24 15:57:07 -0500 |
|---|---|---|
| committer | binarycat <binarycat@envs.net> | 2025-03-24 15:57:07 -0500 |
| commit | c123adf860b008f703b325d013e7c7c0cc707d56 (patch) | |
| tree | 3f8b2930e7348e15c5963cc388d25135a4063612 /src/librustdoc/html/static/js/storage.js | |
| parent | 90f5eab952728ac6edcf529a171f7de5c25e5d49 (diff) | |
| download | rust-c123adf860b008f703b325d013e7c7c0cc707d56.tar.gz rust-c123adf860b008f703b325d013e7c7c0cc707d56.zip | |
rustdoc js: add nonundef and use it to remove a ts-expect-error
Diffstat (limited to 'src/librustdoc/html/static/js/storage.js')
| -rw-r--r-- | src/librustdoc/html/static/js/storage.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index 748d2ef33c3..76113726894 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -44,6 +44,28 @@ function nonnull(x, msg) { } /** + * Assert that the passed value is not undefined, then return it. + * + * Takes an optional error message argument. + * + * Must be defined in this file, as it is loaded before all others. + * + * @template T + * @param {T|undefined} x + * @param {string=} msg + * @returns T + */ +// used in other files, not yet used in this one. +// eslint-disable-next-line no-unused-vars +function nonundef(x, msg) { + if (x === undefined) { + throw (msg || "unexpected null value!"); + } else { + return x; + } +} + +/** * Get a configuration value. If it's not set, get the default. * * @param {string} settingName |
