objects.ts 360 B

12345678910111213141516
  1. // object:可选属性排除出 required、嵌套对象、闭合对象 additionalProperties: false。
  2. interface Address {
  3. city: string;
  4. zip?: string;
  5. }
  6. interface Person {
  7. name: string;
  8. age: number;
  9. address: Address;
  10. nickname?: string;
  11. }
  12. const g = agent("g");
  13. const person = await g.ask<Person>("produce a person");
  14. log(JSON.stringify(person));