Last change
on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | /// <reference lib="es2020.bigint"/>
|
---|
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 a JSON object.
|
---|
24 |
|
---|
25 | 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 { … }`.
|
---|
26 | */
|
---|
27 | export type JsonObject = {[Key in string]?: JsonValue};
|
---|
28 |
|
---|
29 | /**
|
---|
30 | Matches a JSON array.
|
---|
31 | */
|
---|
32 | export interface JsonArray extends Array<JsonValue> {}
|
---|
33 |
|
---|
34 | /**
|
---|
35 | Matches any valid JSON value.
|
---|
36 | */
|
---|
37 | export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
---|
38 |
|
---|
39 | declare global {
|
---|
40 | interface SymbolConstructor {
|
---|
41 | readonly observable: symbol;
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | /**
|
---|
46 | Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
|
---|
47 | */
|
---|
48 | export interface ObservableLike {
|
---|
49 | subscribe(observer: (value: unknown) => void): void;
|
---|
50 | [Symbol.observable](): ObservableLike;
|
---|
51 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.