-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathas-writable.ts
More file actions
19 lines (14 loc) · 574 Bytes
/
as-writable.ts
File metadata and controls
19 lines (14 loc) · 574 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import {type Writable} from 'type-fest';
/**
Cast the given value to be [`Writable`](https://github.com/sindresorhus/type-fest/blob/main/source/writable.d.ts).
This is useful because of a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/45618#issuecomment-908072756).
@example
```
import {asWritable} from 'ts-extras';
const writableContext = asWritable((await import('x')).context);
```
@category General
*/
export function asWritable<T>(value: T): Writable<T> {
return value as any; // eslint-disable-line @typescript-eslint/no-unsafe-return
}