Skip to content

Commit a9e5996

Browse files
committed
Fix type tests
1 parent 25a4626 commit a9e5996

2 files changed

Lines changed: 6 additions & 84 deletions

File tree

src/main.d.ts

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { Styles } from 'chalk-string'
2-
import type figures from 'figures'
1+
import type { Options as BeautifulErrorOptions } from 'beautiful-error'
32

43
/**
54
* Validate `handle-cli-error` options
@@ -9,7 +8,7 @@ export function validateOptions(options: unknown): asserts options is Options
98
/**
109
* `handle-cli-error` options
1110
*/
12-
export interface Options {
11+
export type Options = BeautifulErrorOptions & {
1312
/**
1413
* Process [exit code](https://en.wikipedia.org/wiki/Exit_status).
1514
*
@@ -19,56 +18,13 @@ export interface Options {
1918
*/
2019
readonly exitCode?: number
2120

22-
/**
23-
* Whether to log the `error` stack trace.
24-
*
25-
* @default true
26-
*/
27-
readonly stack?: boolean
28-
29-
/**
30-
* Whether to log the error's additional properties.
31-
*
32-
* @default true
33-
*/
34-
readonly props?: boolean
35-
3621
/**
3722
* Exits the process without logging anything on the console.
3823
*
3924
* @default false
4025
*/
4126
readonly silent?: boolean
4227

43-
/**
44-
* Whether to colorize the error's message, stack trace and additional properties.
45-
*
46-
* Quoted strings in the error's message are printed in bold (for `"..."` and
47-
* `'...'`) and in italic (for `` `...` ``).
48-
*
49-
* @default `true` in terminals, `false` otherwise
50-
*/
51-
readonly colors?: boolean
52-
53-
/**
54-
* Icon prepended to the error's name. The available values are listed
55-
* [here](https://github.com/sindresorhus/figures/blob/main/readme.md#figures-1).
56-
* Can be disabled by passing an empty string.
57-
*
58-
* @default 'cross'
59-
*/
60-
readonly icon?: keyof typeof figures | ''
61-
62-
/**
63-
* Color/style of the error's icon and name. The available values are listed
64-
* [here](https://github.com/ehmicky/chalk-string#available-styles).
65-
* Several styles can be specified by using spaces.
66-
* Can be disabled by passing an empty string.
67-
*
68-
* @default 'red bold'
69-
*/
70-
readonly header?: Styles | ''
71-
7228
/**
7329
* The process exits gracefully: it waits for any ongoing tasks (callbacks,
7430
* promises, etc.) to complete, up to a specific `timeout`.

src/main.test-d.ts

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,58 +11,24 @@ expectAssignable<Options>({})
1111
handleCliError('', true)
1212
expectNotAssignable<Options>(true)
1313

14-
handleCliError('', { exitCode: 0 })
15-
expectAssignable<Options>({ exitCode: 0 })
16-
// @ts-expect-error
17-
handleCliError('', { exitCode: '0' })
18-
expectNotAssignable<Options>({ exitCode: '0' })
19-
2014
handleCliError('', { stack: true })
2115
expectAssignable<Options>({ stack: true })
2216
// @ts-expect-error
2317
handleCliError('', { stack: 'true' })
2418
expectNotAssignable<Options>({ stack: 'true' })
2519

26-
handleCliError('', { props: true })
27-
expectAssignable<Options>({ props: true })
20+
handleCliError('', { exitCode: 0 })
21+
expectAssignable<Options>({ exitCode: 0 })
2822
// @ts-expect-error
29-
handleCliError('', { props: 'true' })
30-
expectNotAssignable<Options>({ props: 'true' })
23+
handleCliError('', { exitCode: '0' })
24+
expectNotAssignable<Options>({ exitCode: '0' })
3125

3226
handleCliError('', { silent: true })
3327
expectAssignable<Options>({ silent: true })
3428
// @ts-expect-error
3529
handleCliError('', { silent: 'true' })
3630
expectNotAssignable<Options>({ silent: 'true' })
3731

38-
handleCliError('', { colors: true })
39-
expectAssignable<Options>({ colors: true })
40-
// @ts-expect-error
41-
handleCliError('', { colors: 'true' })
42-
expectNotAssignable<Options>({ colors: 'true' })
43-
44-
handleCliError('', { icon: '' })
45-
expectAssignable<Options>({ icon: '' })
46-
handleCliError('', { icon: 'warning' })
47-
expectAssignable<Options>({ icon: 'warning' })
48-
// @ts-expect-error
49-
handleCliError('', { icon: 'warn' })
50-
expectNotAssignable<Options>({ icon: 'warn' })
51-
// @ts-expect-error
52-
handleCliError('', { icon: true })
53-
expectNotAssignable<Options>({ icon: true })
54-
55-
handleCliError('', { header: '' })
56-
expectAssignable<Options>({ header: '' })
57-
handleCliError('', { header: 'red bold' })
58-
expectAssignable<Options>({ header: 'red bold' })
59-
// @ts-expect-error
60-
handleCliError('', { header: true })
61-
expectNotAssignable<Options>({ header: true })
62-
// @ts-expect-error
63-
handleCliError('', { header: 'unknown' })
64-
expectNotAssignable<Options>({ header: 'unknown' })
65-
6632
handleCliError('', { timeout: 0 })
6733
expectAssignable<Options>({ timeout: 0 })
6834
handleCliError('', { timeout: 1e3 })

0 commit comments

Comments
 (0)