main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
2.0 KB
|
Line | |
---|
1 | /// <reference lib="esnext"/>
|
---|
2 |
|
---|
3 | // TODO: This can just be `export type Primitive = not object` when the `not` keyword is out.
|
---|
4 | /**
|
---|
5 | Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
---|
6 | */
|
---|
7 | export type Primitive =
|
---|
8 | | null
|
---|
9 | | undefined
|
---|
10 | | string
|
---|
11 | | number
|
---|
12 | | boolean
|
---|
13 | | symbol
|
---|
14 | | bigint;
|
---|
15 |
|
---|
16 | // TODO: Remove the `= unknown` sometime in the future when most users are on TS 3.5 as it's now the default
|
---|
17 | /**
|
---|
18 | Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
|
---|
19 | */
|
---|
20 | export type Class<T = unknown, Arguments extends any[] = any[]> = new(...arguments_: Arguments) => T;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
---|
24 | */
|
---|
25 | export type TypedArray =
|
---|
26 | | Int8Array
|
---|
27 | | Uint8Array
|
---|
28 | | Uint8ClampedArray
|
---|
29 | | Int16Array
|
---|
30 | | Uint16Array
|
---|
31 | | Int32Array
|
---|
32 | | Uint32Array
|
---|
33 | | Float32Array
|
---|
34 | | Float64Array
|
---|
35 | | BigInt64Array
|
---|
36 | | BigUint64Array;
|
---|
37 |
|
---|
38 | /**
|
---|
39 | Matches a JSON object.
|
---|
40 |
|
---|
41 | This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
|
---|
42 | */
|
---|
43 | export type JsonObject = {[Key in string]?: JsonValue};
|
---|
44 |
|
---|
45 | /**
|
---|
46 | Matches a JSON array.
|
---|
47 | */
|
---|
48 | export interface JsonArray extends Array<JsonValue> {}
|
---|
49 |
|
---|
50 | /**
|
---|
51 | Matches any valid JSON value.
|
---|
52 | */
|
---|
53 | export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
---|
54 |
|
---|
55 | declare global {
|
---|
56 | interface SymbolConstructor {
|
---|
57 | readonly observable: symbol;
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | /**
|
---|
62 | Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
|
---|
63 | */
|
---|
64 | export interface ObservableLike {
|
---|
65 | subscribe(observer: (value: unknown) => void): void;
|
---|
66 | [Symbol.observable](): ObservableLike;
|
---|
67 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.