Strapi v4.2.0 beta with TypeScript support & Dark Mode

Hey there, I am really excited about the typescript support! :slight_smile:
Is there an updated documentation, though, showing some simple customization e.g. how to customize a single controller with typescript?

I tried that out, but wasn’t able to replace just the find function for example of a collection type controller, because:

  1. The factories.d.ts definition of the createCoreController function requires a complete Controller type input, meaning if I want to provide that input parameter, typescript requires me to define a complete set of the functions find, findOne, create, update, delete, transformResponse, sanitizeOutput, sanitizeInput. That should not be necessary, though, as the actual implementation of the createCoreController function is checking which functions are provided and will overwrite just those. Shouldn’t the type definition use Partial<> or something here to allow only a subgroup of the functions as input?

  2. Also the input does not accept a function, but just the Controller type directly. Means, I cannot inject the strapi object into my controller functions. Again, the actual implementation of createCoreController has a check (typeof cfg === 'function'), but the type definition does not allow me a function as parameter.

2 Likes