Skip to main content
This rule requires that run and onSuccess exports use the generated ActionRun and ActionOnSuccess types from gadget-server. These types are auto-generated based on your action’s configuration and provide accurate type checking for parameters and context.

Rule Details

This rule checks that:
  • run exports are typed as ActionRun
  • onSuccess exports are typed as ActionOnSuccess
  • Manual type annotations are replaced with generated types
  • Missing type annotations are added
Severity: Error Auto-fixable: Yes

Examples

Incorrect

Correct

Auto-fixes

The rule automatically:
  1. Adds the type annotation if missing
  2. Replaces manual types with generated types
  3. Adds imports to gadget-server if needed

Why Use Generated Types

The ActionRun and ActionOnSuccess types are auto-generated by Gadget based on:
  • Your action’s params definition
  • Whether it’s a model or global action
  • The model’s fields (for model actions)
  • Your action’s options
These types provide:
  • Accurate autocompletion for the context object
  • Type checking for parameters
  • Proper typing for record fields
  • Compile-time errors if you access undefined fields
Using the generated types gives you full type safety and autocompletion based on your specific action configuration.

When to Use

This rule is included in the recommended config and should always be enabled for Gadget projects. It ensures you get the full benefit of TypeScript type checking for your actions.