Skip to content

[bug]: Strapi v5 Typescript create plugin not finding types #62

@tomh4

Description

@tomh4

What version of @strapi/sdk-plugin are you using?

  • npm version: 10.5.0
  • Node version: v18.20.2
  • Strapi Version: 5.0.2
  • Plugin version: 5.2.6

What's Wrong?

When trying to create a new plugin with strapi 5 and typescript, strapi can no longer be started if plugin is used inside strapi.
While creating the plugin the following warnings appear:

[18:40:34.406] [0] $ npm install
[18:41:32.113] [0]   npm WARN ERESOLVE overriding peer dependency
[18:41:32.114] [0]   npm WARN While resolving: msw@1.3.0
[18:41:32.114] [0]   npm WARN Found: typescript@5.3.2
[18:41:32.114] [0]   npm WARN node_modules/@strapi/admin/node_modules/typescript
[18:41:32.114] [0]   npm WARN   typescript@"5.3.2" from @strapi/admin@5.0.4
[18:41:32.114] [0]   npm WARN   node_modules/@strapi/admin
[18:41:32.115] [0]   npm WARN     @strapi/admin@"5.0.4" from @strapi/strapi@5.0.4
[18:41:32.115] [0]   npm WARN     node_modules/@strapi/strapi
[18:41:32.115] [0]   npm WARN     8 more (@strapi/content-manager, @strapi/content-releases, ...)
[18:41:32.116] [0]   npm WARN   1 more (react-intl)
[18:41:32.116] [0]   npm WARN 
[18:41:32.116] [0]   npm WARN Could not resolve dependency:
[18:41:32.116] [0]   npm WARN peerOptional typescript@">= 4.4.x <= 5.2.x" from msw@1.3.0
[18:41:32.116] [0]   npm WARN node_modules/@strapi/admin/node_modules/msw
[18:41:32.116] [0]   npm WARN   msw@"1.3.0" from @strapi/admin@5.0.4
[18:41:32.116] [0]   npm WARN   node_modules/@strapi/admin
[18:41:32.116] [0]   npm WARN 
[18:41:32.116] [0]   npm WARN Conflicting peer dependency: typescript@5.2.2
[18:41:32.116] [0]   npm WARN node_modules/typescript
[18:41:32.117] [0]   npm WARN   peerOptional typescript@">= 4.4.x <= 5.2.x" from msw@1.3.0
[18:41:32.117] [0]   npm WARN   node_modules/@strapi/admin/node_modules/msw
[18:41:32.117] [0]   npm WARN     msw@"1.3.0" from @strapi/admin@5.0.4
[18:41:32.117] [0]   npm WARN     node_modules/@strapi/admin

when starting the app the following error appears:

plugins/new-plugin/admin/src/pages/App.tsx:1:22 - error TS2307: Cannot find module '@strapi/strapi/admin' or its corresponding type declarations.

1 import { Page } from '@strapi/strapi/admin';

To Reproduce

  • Create a new Strapi project with Typescript
  • Create a new plugin inside the Strapi project : npx @strapi/sdk-plugin init plugins/new-plugin
  • Say Y to everything
  • Add the plugin to the config file as told by the instructions:
[INFO] 
You can now enable your plugin by adding the following in ./config/plugins.ts
────────────────────────────────────────────
export default {
  // ...
  'generate-recipe': {
    enabled: true,
    resolve: 'plugins/new-plugin'
  },
  // ...
}
  • run npm run develop

Expected Behaviour

App loads

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugseverity: highIf it breaks the basic use of the productstatus: can not reproduceNot enough information to reproducestatus: pending reproductionWaiting for free time to reproduce the issue, or more information

    Type

    No type

    Projects

    Status

    Fixed/Shipped

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions