Skip to content

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

@Char2sGu

Description

@Char2sGu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BREAKING CHANGEIndicates a breaking changetype: featureIndicates a feature or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions