-
-
Notifications
You must be signed in to change notification settings - Fork 679
Expand file tree
/
Copy patharrayable.d.ts
More file actions
31 lines (23 loc) · 659 Bytes
/
arrayable.d.ts
File metadata and controls
31 lines (23 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
Create a type that represents either the value or an array of the value.
@see {@link Promisable}
@example
```
import type {Arrayable} from 'type-fest';
function bundle(input: string, output: Arrayable<string>) {
const outputList = Array.isArray(output) ? output : [output];
// …
for (const output of outputList) {
console.log(`write to: ${output}`);
}
}
bundle('src/index.js', 'dist/index.js');
bundle('src/index.js', ['dist/index.cjs', 'dist/index.mjs']);
```
@category Array
*/
export type Arrayable<T> =
T
// TODO: Use `readonly T[]` when this issue is resolved: https://github.com/microsoft/TypeScript/issues/17002
| T[];
export {};