简中文档

Built-in TypeScript support

Edit on 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 }));

Run this example locally using the Deno CLI:

deno run https://docs.deno.com/examples/scripts/typescript_support.ts

Additional resources

你找到了你需要的东西吗?

编辑此页面
隐私政策