Merge pull request #13749 from strapi/typescript/fix/typings

[TS] Fix light typings issues
This commit is contained in:
Jean-Sébastien Herbaux 2022-07-12 16:35:04 +02:00 committed by GitHub
commit ea1ae545cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 7 deletions

View File

@ -1,4 +1,5 @@
import type Koa from 'koa';
import { Database } from '@strapi/database';
import type { StringMap } from './utils';
import type { GenericController } from '../core-api/controller'
@ -335,6 +336,26 @@ export interface Strapi {
* Telemetry util used to collect anonymous data on the application usage
*/
telemetry: any;
/**
* Strapi DB layer instance
*/
db: Database;
/**
* Core Store accessor
*/
store: any;
/**
* Entity Validator instance
*/
entityValidator: any;
/**
* Entity Service instance
*/
entityService: any;
}
export interface Lifecycles {

View File

@ -2,7 +2,7 @@ import { Service } from '../core-api/service';
import { Controller, GenericController } from '../core-api/controller';
import { Middleware } from '../middlewares';
import { Policy } from '../core/registries/policies';
import { Strapi } from '@strapi/strapi'
import { Strapi } from '@strapi/strapi';
type ControllerConfig<T extends Controller = Controller> = T;
@ -10,8 +10,8 @@ type ServiceConfig = Service;
type HandlerConfig = {
auth?: false | { scope: string[] };
policies?: Array<string | Policy>;
middlewares?: Array<string | Middleware>;
policies?: Array<string | Policy | { name: string; config: object }>;
middlewares?: Array<string | Middleware | { name: string; config: object }>;
};
type SingleTypeRouterConfig = {
@ -44,9 +44,17 @@ interface Router {
routes: Route[];
}
type ControllerCallback <T extends GenericController = GenericController> = (params:{strapi:Strapi}) => T;
type ServiceCallback <T extends Service = Service> = (params:{strapi:Strapi}) => T
type ControllerCallback<T extends GenericController = GenericController> = (params: {
strapi: Strapi;
}) => T;
type ServiceCallback<T extends Service = Service> = (params: { strapi: Strapi }) => T;
export function createCoreRouter(uid: string, cfg?: RouterConfig = {}): () => Router;
export function createCoreController<T extends GenericController = GenericController>(uid: string, cfg?: ControllerCallback<T> | T = {}): () => T & Controller;
export function createCoreService<T extends Service = Service>(uid: string, cfg?: ServiceCallback<T> | T = {}): () => T ;
export function createCoreController<T extends GenericController = GenericController>(
uid: string,
cfg?: ControllerCallback<T> | T = {}
): () => T & Controller;
export function createCoreService<T extends Service = Service>(
uid: string,
cfg?: ServiceCallback<T> | T = {}
): () => T;