@kkdev92/vscode-ext-kit - v4.1.1
    Preparing search index...

    Function defineModule

    • Declares a module.

      This is a definition-phase callback: keep it to builder calls rather than touching vscode, performing I/O, starting timers or creating service instances. Those side effects are outside the framework lifecycle and Test Host guarantees. A thenable return is rejected at runtime because TypeScript accepts an async function wherever a void callback is expected.

      Type Parameters

      • TUses extends Readonly<Record<string, ServiceToken<unknown>>> = Record<never, never>

      Parameters

      Returns ModuleDefinition

      when no configure callback is supplied, a service or command registration lacks its required callback, or a local inject name duplicates one from uses.

      when configure returns a thenable. No ModuleDefinition is returned in either case.

      export const projectsModule = defineModule('projects', (module): undefined => {
      module.services.singleton(ProjectRepository, {
      inject: { clock: Clock },
      create: ({ clock }) => new DefaultProjectRepository(clock),
      });

      module.commands.handle(RefreshProjects, {
      inject: { repository: ProjectRepository },
      execute: (context, [options], { repository }) =>
      repository.refresh(options, context.signal),
      });

      return undefined;
      });

      Options may come before or after the callback. This order — options second — is the one to use when there are any: with them last the call wraps, and the whole module body gains a level of indentation for the sake of one word.

    • Defines a module with no options, or with them trailing the callback.

      Prefer this form when there are no options: the id and the callback on one line is the shortest thing that says what the module is.

      Type Parameters

      • TUses extends Readonly<Record<string, ServiceToken<unknown>>> = Record<never, never>

      Parameters

      Returns ModuleDefinition