How to use TypeScript with lifecycle hooks?

System Information
  • Strapi Version: 4.14.3
  • Operating System: macOS
  • Database: MySQL
  • Node Version: 16
  • NPM Version: 8
  • Yarn Version:

What is the type of event?

// src/api/page/content-types/page/lifecycles.ts

export default {
  afterUpdate(event: ???) {
    console.log(event);
  }
};

EDIT

Best type I found is:

import { Event } from '@strapi/database/lib/lifecycles';

If this is the correct type to use it would be nice to export it at the top level, or provide a type for the object exported:

const config: Strapi.Lifecycles = {
  afterUpdate(event) {
    // event type is correctly inferred as `Event`
  }
};
export default config;
1 Like

I’ve just run into this same issue.
How has this type been working out for you so far?

in 2025, using this

import { type Event } from '@strapi/database/dist/lifecycles';