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; }”的參數(shù)不能賦給類型“Person”的參數(shù)。
Type '{ firstName: string; lastName: string; }' is missing the following properties from type 'Person': name, age, getName明明接口沒有定義name, age, getName為啥說我缺失?
添加回答
舉報
0/150
提交
取消