common.d.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /** The common type namespace */
  2. declare namespace CommonType {
  3. /** The strategic pattern */
  4. interface StrategicPattern {
  5. /** The condition */
  6. condition: boolean;
  7. /** If the condition is true, then call the action function */
  8. callback: () => void;
  9. }
  10. /**
  11. * The option type
  12. *
  13. * @property value: The option value
  14. * @property label: The option label
  15. */
  16. type Option<K = string, M = string> = { value: K; label: M };
  17. /** The record type */
  18. type Record<K extends string | number = string> = { [key in K]: string };
  19. type YesOrNo = 'Y' | 'N';
  20. /** add null to all properties */
  21. type RecordNullable<T> = {
  22. [K in keyof T]?: T[K] | null;
  23. };
  24. /** The id type */
  25. type IdType = string | number;
  26. /** The res error code */
  27. type ErrorCode = '401' | '403' | '404' | 'default';
  28. /** The configuration options for constructing tree structure data */
  29. type TreeConfig = {
  30. /** id field name */
  31. idField: string;
  32. /** parent id field name */
  33. parentIdField?: string;
  34. /** children field name */
  35. childrenField?: string;
  36. /** filter function */
  37. filterFn?: (node: any) => boolean;
  38. };
  39. }