-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Labels
issue: bugIssue reporting a bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundIf it breaks the basic use of the product but can be worked aroundstatus: confirmedConfirmed by a Strapi Team member or multiple community membersConfirmed by a Strapi Team member or multiple community members
Description
Bug report
Describe the bug
Strapi comes with two different typing system:
- One that is used internally
import type { StrapiInterface } from '@strapi/strapi'
function myFunction(strapi: StrapiInterface) {
// here we use the internal strapi interface
}import { factories } from '@strapi/strapi'
const { createCoreController } = factories
export default createCoreController('api::foo:foo', ({ strapi }) => {
// here we also use the internal strapi interface
}- One that is exposed globally
function myFunction() {
// here we use the global strapi interface
strapi.log.debug('it works')
}The interfaces used for internal typing are not exported, so we can not do:
declare module '@strapi/strapi' {
// use declaration merging
interface StrapiInterface {
plugin: (pluginName: 'my-plugin') => any;
}
}For now we can do something quite similar for the global part, but il would break all typing provided by arguments on factories.
declare global {
interface StrapiInterface {
plugin: (pluginName: string) => any;
}
interface AllTypes {
[key: string]: unknown;
foo: any;
}
}Also the default Strapi Class is not considered in end project because of the type overriding (@strapi/strapi/lib/index.d.ts, when .d.ts file is present, typescript just ignore .js files), so we end up with only query and entityService as Strapi object member:

Expected behavior
The internal type should be the reference and the only interface that need to be updated.
christophemacabiau and maxep
Metadata
Metadata
Assignees
Labels
issue: bugIssue reporting a bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundIf it breaks the basic use of the product but can be worked aroundstatus: confirmedConfirmed by a Strapi Team member or multiple community membersConfirmed by a Strapi Team member or multiple community members