diff --git a/examples/kitchensink-ts/index.d.ts b/examples/kitchensink-ts/index.d.ts new file mode 100644 index 0000000000..9f6a06269f --- /dev/null +++ b/examples/kitchensink-ts/index.d.ts @@ -0,0 +1,7 @@ +import '@strapi/strapi'; + +declare module '@strapi/strapi' { + interface StrapiInterface { + customAddMethod(n1: number, n2: number): number; + } +} diff --git a/examples/kitchensink-ts/src/index.ts b/examples/kitchensink-ts/src/index.ts new file mode 100644 index 0000000000..c8c0cfbe0e --- /dev/null +++ b/examples/kitchensink-ts/src/index.ts @@ -0,0 +1,15 @@ +export default { + register({ strapi }: { strapi: Strapi }) { + // No error when trying the access & set the + strapi.customAddMethod = (n1, n2) => { + return n1 + n2; + }; + }, + + bootstrap({ strapi }: { strapi: Strapi }) { + const result = strapi.customAddMethod(12, 32); + + // This should print "42" + console.log(result); + }, +};