interface Person {
firstName: string;
lastName: string;
}function greeter(person: Person) { return "Hello, " + person.firstName + " " + person.lastName;
}let user = { firstName: "Jane", lastName: "User" };document.body.innerHTML = greeter(user);这段代码ts代码编译没问题但是TSLint却报了一个很诡异的错类型“{ firstName: string; lastName: string; }”的参数不能赋给类型“Person”的参数。
Type '{ firstName: string; lastName: string; }' is missing the following properties from type 'Person': name, age, getName明明接口没有定义name, age, getName为啥说我缺失?
添加回答
举报
0/150
提交
取消