Why doesn't strapi infer body properties in custom controllers but it does in pligins?

Hello community, I hope you are doing well.

Well the question is that for my project I had to customize several endpoints. In my users-permissions/strapi-server.js file I made use of the plugin to add those endpoints to the strapi users controller. I didn’t have too many complications and everything worked fine.

module.exports = (plugin) => {

  plugin.controllers.user.sendCode = async (ctx) => {

            if ( ctx.request.body.username || ctx.request.body.email ) {
//works well with the body and the paramenters 

The problem came when I wanted to make custom endpoints for the entities of the project, every time I wanted to access the body property of the ctx I get an error that says “The property ‘body’ does not exist in type ‘unknown’.ts(2339)”. A behaviour that doesn’t happen with the plugin endpoints.

module.exports = createCoreController('api:example.Example', ({strapi}) =>({
    async customAction (ctx) {
        try {
            ctx.body;
        } catch (error) {
            ctx.body = error;
        }
    }
}));

//The property 'body' does not exist in type 'unknown'.ts(2339)

I would like to know why this happens in strapi and if it is possible to solve this error in the entity controllers. Because otherwise I would put those endpoints users-permissions/strapi-server.js; I know it’s not the right place for anything but it’s the feasible solution I see.

Thank you very much and have a nice day

Hi,
You can directly type the body since its type is unknown

interface IBody { 
    data?: {
        text_field: string;
        // Your properties
    }
}

module.exports = createCoreController('api:example.Example', ({strapi}) =>({
    async customAction (ctx) {
        const body = ctx.request.body;
        
    // ...
    }
}));