ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
>[success] # 类作为类型 ~~~ 1.类也可以声明一个类型和接口类型一样的效果 ~~~ ~~~ class A { name: string; constructor(name: string) { this.name = name; } } const a1: A = {}; // ts(2741) Property 'name' is missing in type '{}' but required in type 'A'. const a2: A = { name: 'a2' }; // ok ~~~