@@ -34,7 +34,7 @@ export let commandkit: CommandKit;
3434
3535export class CommandKit extends EventEmitter {
3636 #started = false ;
37- public readonly eventInterceptor : EventInterceptor ;
37+ public eventInterceptor ! : EventInterceptor ;
3838
3939 public static readonly createElement = createElement ;
4040 public static readonly Fragment = Fragment ;
@@ -60,7 +60,7 @@ export class CommandKit extends EventEmitter {
6060 * @param options - The default CommandKit configuration.
6161 * @see {@link https://commandkit.js.org/docs/guide/commandkit-setup }
6262 */
63- constructor ( private options : CommandKitOptions ) {
63+ constructor ( private readonly options : CommandKitOptions ) {
6464 if ( CommandKit . instance ) {
6565 process . emitWarning (
6666 'CommandKit instance already exists. Having multiple instance in same project is discouraged and it may lead to unexpected behavior.' ,
@@ -86,7 +86,6 @@ export class CommandKit extends EventEmitter {
8686 options . cacheProvider = new MemoryCache ( ) ;
8787 }
8888
89- this . eventInterceptor = new EventInterceptor ( options . client ) ;
9089 this . plugins = new CommandKitPluginRuntime ( this ) ;
9190
9291 if ( ! CommandKit . instance ) {
@@ -104,6 +103,14 @@ export class CommandKit extends EventEmitter {
104103 async start ( token ?: string | false ) {
105104 if ( this . #started) return ;
106105
106+ if ( ! this . options . client ) {
107+ throw new Error (
108+ colors . red ( '"client" is required when starting CommandKit.' ) ,
109+ ) ;
110+ }
111+
112+ this . eventInterceptor = new EventInterceptor ( this . client ) ;
113+
107114 if ( COMMANDKIT_IS_DEV ) {
108115 try {
109116 registerDevHooks ( this ) ;
0 commit comments