TypeScript
Extend a CustomEvent

by Benny Neugebauer

interface CreateSSOAccountDetail {
  reachedMaximumAccounts: boolean
}

// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#customevent-is-now-a-generic-type
class CreateSSOAccountResponse extends CustomEvent<CreateSSOAccountDetail> {
  constructor(eventName: string, detail: CustomEventInit<CreateSSOAccountDetail>) {
    super(eventName, detail);
  }
}

class AutomatedSingleSignOn {
  private onResponseReceived(event: CreateSSOAccountResponse) {
    if (event.detail.reachedMaximumAccounts) {
      this.showError();
    }
  }
}

export interface CreateSSOAccountResponse {
  reachedMaximumAccounts: boolean
};

class AutomatedSingleSignOn {
  private onResponseReceived(event: CustomEvent<CreateSSOAccountResponse>) {
    if (event.detail.reachedMaximumAccounts) {
      this.showError();
    }
  }
}