jsdoc.ts 763 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // JSDoc 采集:description、数值/字符串约束标签、@default,以及顶层类型的 description。
  2. /**
  3. * A validated registration form.
  4. */
  5. interface Registration {
  6. /**
  7. * Chosen username.
  8. * @minLength 3
  9. * @maxLength 20
  10. * @pattern ^[a-z0-9_]+$
  11. */
  12. username: string;
  13. /**
  14. * Age in years.
  15. * @minimum 13
  16. * @exclusiveMaximum 130
  17. */
  18. age: number;
  19. /**
  20. * Contact email.
  21. * @format email
  22. */
  23. email: string;
  24. /**
  25. * Interests.
  26. * @minItems 1
  27. * @maxItems 5
  28. */
  29. interests: string[];
  30. /**
  31. * Whether to subscribe to the newsletter.
  32. * @default false
  33. */
  34. subscribe: boolean;
  35. }
  36. const g = agent("g");
  37. const registration = await g.ask<Registration>("fill the form");
  38. log(JSON.stringify(registration));