Add todo and unreachable

This commit is contained in:
timongh 2023-05-02 14:26:31 +08:00 committed by GitHub
parent 9576cfc7df
commit 723ab8f352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -638,3 +638,36 @@ export const getRandomId = (length = 8) => {
.join('')
.substring(0, length)
}
/**
* eslintIDE
*
* @example
* ```typescript
* const uncompleted = (arg1: number, arg2: string): number => {
* return todo(arg1, arg2)
* }
* ```
*/
export const todo = (...args: unknown[]): never => {
throw new Error(`todo. args: ${JSON.stringify(args)}`)
}
/**
*
*
* @example
* ```typescript
* switch (code) {
* case 0:
* return 0
* case 1:
* return 1
* default:
* unreachable()
* }
* ```
*/
export const unreachable = (): never => {
throw new Error(`unreachable`)
}