mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Merge tag 'v0.1.21' of github.com:google-gemini/gemini-cli into chore/sync-gemini-cli-v0.1.21
This commit is contained in:
28
packages/cli/src/utils/checks.ts
Normal file
28
packages/cli/src/utils/checks.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user