📜  强类型与松散类型 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:56.530000             🧑  作者: Mango

代码示例1
interface User {  name: string;  id: number;}
const user: User = {  username: "Hayes",Type '{ username: string; id: number; }' is not assignable to type 'User'.
  Object literal may only specify known properties, and 'username' does not exist in type 'User'.2322Type '{ username: string; id: number; }' is not assignable to type 'User'.
  Object literal may only specify known properties, and 'username' does not exist in type 'User'.  id: 0,};Try