e5cb0e779c6f2da3e75712e6bad987cf84d9cd18ac15fa959f0ecbdd1b5ea042599f74a942fec616ba2ec3f3a744315eef4054769921c765a149b9a437ad92 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /// <reference lib="es2020.bigint"/>
  2. // TODO: This can just be `export type Primitive = not object` when the `not` keyword is out.
  3. /**
  4. Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
  5. */
  6. export type Primitive =
  7. | null
  8. | undefined
  9. | string
  10. | number
  11. | boolean
  12. | symbol
  13. | bigint;
  14. // TODO: Remove the `= unknown` sometime in the future when most users are on TS 3.5 as it's now the default
  15. /**
  16. Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
  17. */
  18. export type Class<T = unknown, Arguments extends any[] = any[]> = new(...arguments_: Arguments) => T;
  19. /**
  20. Matches a JSON object.
  21. 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 { … }`.
  22. */
  23. export type JsonObject = {[Key in string]?: JsonValue};
  24. /**
  25. Matches a JSON array.
  26. */
  27. export interface JsonArray extends Array<JsonValue> {}
  28. /**
  29. Matches any valid JSON value.
  30. */
  31. export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
  32. declare global {
  33. interface SymbolConstructor {
  34. readonly observable: symbol;
  35. }
  36. }
  37. /**
  38. Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).
  39. */
  40. export interface ObservableLike {
  41. subscribe(observer: (value: unknown) => void): void;
  42. [Symbol.observable](): ObservableLike;
  43. }