Type definition in object literal in TypeScript

后端 未结 9 2509
粉色の甜心
粉色の甜心 2020-11-27 09:29

In TypeScript classes it\'s possible to declare types for properties, for example:

class className {
  property: string;
};

How do declare

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 09:56

    In TypeScript if we are declaring object then we'd use the following syntax:

    [access modifier] variable name : { /* structure of object */ }
    

    For example:

    private Object:{ Key1: string, Key2: number }
    

提交回复
热议问题