Skip to main content

TypeScript

4.3.0This feature requires Strapi version 4.3.0 or later.

TypeScript 在 JavaScript 之上增加了一层额外的类型系统,这意味着任何有效的 JavaScript 代码也是有效的 TypeScript 代码。在 Strapi 开发的背景下,TypeScript 允许你的应用拥有更类型安全的代码库,并为你提供一套用于自动类型生成和自动补全的工具。

在 Strapi 中使用 TypeScript 入门

🌐 Getting Started with TypeScript in Strapi

在 Strapi 中开始使用 TypeScript 有两种方法:

🌐 There are 2 ways of getting started with TypeScript in Strapi:

  • 通过在终端中运行以下命令,在 Strapi 中创建一个新的 TypeScript 项目(更多详细信息请参见 CLI 安装 文档):

    yarn create strapi-app my-project --typescript
  • 使用提供的 conversion 步骤为现有的 Strapi 项目添加 TypeScript 支持。


What to do next?