Built-in TypeScript support
在 Github 上编辑
Deno natively understands TypeScript code with no compiler to configure. Start writing code in .ts files, and the runtime will work with them just fine.
Define an interface in TypeScript
interface Person {
name: string;
age: number;
}
Provide a typed input to a function
function greet(person: Person) {
return "Hello, " + person.name + "!";
}
Everything works with zero config!
console.log(greet({ name: "Alice", age: 36 }));
使用 Deno CLI 在本地运行 此示例:
deno run https://docs.denohub.com/examples/scripts/typescript_support.ts