chore(build/compiler): Enable a bunch of strict TS compiler options. (#6138)

This commit is contained in:
Richie Foreman
2025-08-13 16:17:38 -04:00
committed by GitHub
parent 8fae227e8d
commit a90aeb3d8f
28 changed files with 141 additions and 84 deletions

View File

@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/* Fail to compile on unexpected values. */
export function assumeExhaustive(_value: never): void {}
/**
* Throws an exception on unexpected values.
*
* A common use case is switch statements:
* switch(enumValue) {
* case Enum.A:
* case Enum.B:
* break;
* default:
* checkExhaustive(enumValue);
* }
*/
export function checkExhaustive(
value: never,
msg = `unexpected value ${value}!`,
): never {
assumeExhaustive(value);
throw new Error(msg);
}