尝试写了一个typescript的接口,语法还是挺好学的。
编辑器用的是vscode,安装了 node-ts
代码如下
interface Person {
firstName: String;
lastName: String;
}
function greeter(person: Person) {
return "Hello " + person.firstName + " " + person.lastName;
}
let user = { firstName: "jack", lastName: "abc" };
console.log(greeter(user));
网友评论