angular-notifier icon indicating copy to clipboard operation
angular-notifier copied to clipboard

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

Open Char2sGu opened this issue 2 years ago • 0 comments

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, ...) {
    ...
  }
  ...
}

Char2sGu avatar Oct 01 '21 11:10 Char2sGu