Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot dynamically set Toast severity #1955

Closed
slumtrimpet opened this issue Jan 7, 2022 · 0 comments
Closed

Cannot dynamically set Toast severity #1955

slumtrimpet opened this issue Jan 7, 2022 · 0 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@slumtrimpet
Copy link

Breaking our discussion into a new separate issue as requested from:
#1856

This is my usage of toast:

      if (resp != 'OK') {
        let severity = 'info';
        let summary = 'System Status';
        if (resp.indexOf('ERROR') >= 0) {
          severity = 'error';
          summary = 'Validation Error';
        }
        toast.add({
          severity: severity,
          summary: summary,
          detail: resp,
          life: 3000,
        });
      }

With the current implementation, there's not a way to dynamically set 'severity' as typescript can't evaluate that our local variable is one of the valid options from https://github.com/primefaces/primevue/blob/master/src/components/toast/Toast.d.ts#L6.

VSCode gripes about the severity usage above with:
toast

@yigitfindikli yigitfindikli added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Jan 17, 2022
@yigitfindikli yigitfindikli added this to the 3.10.1 milestone Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants