From 5647c79d5744a0e3d41247d222ab09c94fd4bda6 Mon Sep 17 00:00:00 2001 From: Pierre Wizla Date: Mon, 22 Sep 2025 17:34:15 +0200 Subject: [PATCH] docs: fix typescript Strapi import example --- docusaurus/docs/cms/typescript/development.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docusaurus/docs/cms/typescript/development.md b/docusaurus/docs/cms/typescript/development.md index 8060affdf4..caf020741a 100644 --- a/docusaurus/docs/cms/typescript/development.md +++ b/docusaurus/docs/cms/typescript/development.md @@ -33,18 +33,20 @@ Strapi provides typings on the `Strapi` class to enhance the TypeScript developm To experience TypeScript-based autocomplete while developing Strapi applications, you could try the following: 1. Open the `./src/index.ts` file from your code editor. -2. Declare the `strapi` argument as type `Strapi` within the global `register` method: +2. Declare the `strapi` argument with the `Core.Strapi` type exported from `@strapi/strapi` within the global `register` method: ```typescript title="./src/index.ts" - import { Strapi } from '@strapi/strapi'; + import type { Core } from '@strapi/strapi'; export default { - register({ strapi }: { strapi: Strapi }) { + register({ strapi }: { strapi: Core.Strapi }) { // ... }, }; ``` + The `Core` namespace re-exported by `@strapi/strapi` exposes the `Strapi` type that powers TypeScript autocompletion while keeping the runtime import free of unused bindings. + 3. Within the body of the `register` method, start typing `strapi.` and use keyboard arrows to browse the available properties. 4. Choose `runLifecyclesFunctions` from the list.