dominique-mueller / angular-notifier

A well designed, fully animated, highly customizable, and easy-to-use notification library for your Angular application.
https://www.npmjs.com/package/angular-notifier
MIT License
247 stars 68 forks source link

feat(type): specify a stricter type for the `type` argument #222

Open Char2sGu opened 3 years ago

Char2sGu commented 3 years ago

The current type of the type argument is string, which may cause errors if we typed a wrong value.

But if we specify the type to 'default' | 'info' | 'success' | 'warning' | 'error', we can have not only stricter type checks but also auto-completion support from the editor.

type NotificationType = 'default' | 'info' | 'success' | 'warning' | 'error';

class NotifierService {
  ...
  notify(type: NotificationType, ...) {
    ...
  }
  ...
}