gpt4 book ai didi

typescript - Typescript "Anonymous"类型定义的正确名称是什么?

转载 作者:行者123 更新时间:2023-12-04 01:55:34 28 4
gpt4 key购买 nike

我正在查看这行代码 options?: { name?: string, async?: boolean }{ name?: string, async?: boolean } 类型的正确术语是什么?它看起来像 Java 中的“匿名类”定义,但我猜它被称为其他东西......

最佳答案

根据 Typescript 语言规范,这些称为 Object Type Literals :

An object type literal defines an object type by specifying the set of members that are statically considered to be present in instances of the type. Object type literals can be given names using interface declarations but are otherwise anonymous.

  ObjectType:
   {TypeBodyopt}

  TypeBody:
   TypeMemberList;opt
   TypeMemberList,opt

  TypeMemberList:
   TypeMember
   TypeMemberList;TypeMember
   TypeMemberList,TypeMember

  TypeMember:
   PropertySignature
   CallSignature
   ConstructSignature
   IndexSignature
   MethodSignature

关于typescript - Typescript "Anonymous"类型定义的正确名称是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50899262/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com