完全支持 TypeScript
¥Full TypeScript support
要使用完全支持所有 TypeScript 功能(包括 tsconfig.json
)的 TypeScript,你可以使用第三方包。这些说明使用 tsx
作为示例,但还有许多其他类似的库可用。
¥To use TypeScript with full support for all TypeScript features, including
tsconfig.json
, you can use a third-party package. These instructions use
tsx
as an example but there are many other similar libraries available.
-
使用你为项目使用的任何包管理器将包安装为开发依赖。例如,对于
npm
:¥Install the package as a development dependency using whatever package manager you're using for your project. For example, with
npm
:npm install --save-dev tsx
-
然后你可以通过以下方式运行 TypeScript 代码:
¥Then you can run your TypeScript code via:
npx tsx your-file.ts
或者,你可以通过以下方式使用
node
运行:¥Or alternatively, you can run with
node
via:node --import=tsx your-file.ts