📜  输入 deno - TypeScript (1)

📅  最后修改于: 2023-12-03 15:28:17.274000             🧑  作者: Mango

Introducing Deno - TypeScript

Deno is a secure runtime for JavaScript/TypeScript. It was created by the original creator of Node.js, Ryan Dahl, with the goal of fixing some of the issues that have been present in Node.js since its inception.

Features of Deno
  • Secure by default: Deno doesn't allow access to the file system, network or environment variables unless explicitly given permission by the user.
  • Supports TypeScript natively: TypeScript is fully supported in Deno, and can be used out of the box without any configuration.
  • Modern APIs: Deno comes with a number of modern APIs, like fetch, WebSocket and WebSockets.
  • Easy dependency management: Dependencies are referenced via URLs, making it easy to update or switch to a different version of a package.
  • Built-in testing: Deno comes with a testing framework built-in, making it easy to write and run tests for your code.
Getting started with Deno and TypeScript

To get started with Deno and TypeScript, you'll need to have them both installed on your machine. Here's how you can do that:

  1. Install Deno by following the instructions on deno.land.
  2. Install TypeScript by running npm install -g typescript.

Once you have Deno and TypeScript installed, you can create a new TypeScript file by running:

touch main.ts

Then, open the file in your favorite text editor and add the following code:

console.log('Hello, world!');

To run the code, simply execute the following command in your terminal:

deno run main.ts

You should see Hello, world! printed to your terminal.

Conclusion

Deno is an exciting new runtime for JavaScript/TypeScript that offers a number of features that Node.js doesn't have. If you're interested in learning more, check out the Deno documentation.