我是一名Python软件工程师,也是Typescript的初学者,目前正在开发Angular应用程序。关于我为什么以及如何使用类和实例的理解,我时不时地会感到惊讶,并且我正在寻找经验丰富的建议。具体来说,考虑一个类似的类:
class User {
constructor(public name: string, ...many more instance attributes);
upperCase() {return this.name.upper();}
// ...many more methods that use instance state
}
return http.get<User>.pipe(map(user => new User(user)))
,以便客户端可以确定其实际处理的内容,实例检查始终按预期执行并且缺少的方法不会引发错误?我是一名Python软件工程师,也是Typescript的初学者,目前正在开发Angular应用程序。关于我为什么理解...
打字稿是structurally typed, not nominally typed,就像您惯用的一样,您似乎想回到的文字。