Skip to main content
Question

Figma notify with error not according to docs


Pedro8

According to the docs for the notify function:

However, when I add error field I am getting:


Argument of type '{ timeout: number; error: boolean; }' is not assignable to parameter of type 'NotificationOptions'.
  Object literal may only specify known properties, and 'error' does not exist in type 'NotificationOptions'.ts(2345)

I might be doing something wrong here, but looks like a contradiction between docs and error message.

this is the line: figma.notify(errorMessage, {timeout: 5000, error: true});

6 replies

tank666
  • 4863 replies
  • July 7, 2022
figma.notify('Your message', {timeout: 4000, error: true});

Pedro8
  • Author
  • 9 replies
  • July 7, 2022

@tank666 yes, this is my line I just edited my question, interesting enough it works without error field, but of course it is not showed in red as an error.

Even more interesting, if I navigate inside the implementation of the notify function I can see:

notify(message: string, options?: NotificationOptions): NotificationHandler

and for NotificationOptions I can also see a couple of implementations, none of them has the error property.

from lib.dom.d.ts:

interface NotificationOptions {
    actions?: NotificationAction[];
    badge?: string;
    body?: string;
    data?: any;
    dir?: NotificationDirection;
    icon?: string;
    image?: string;
    lang?: string;
    renotify?: boolean;
    requireInteraction?: boolean;
    silent?: boolean;
    tag?: string;
    timestamp?: EpochTimeStamp;
    vibrate?: VibratePattern;
}

from index.d.ts

 interface NotificationOptions {
    timeout?: number
  }

tank666
  • 4863 replies
  • July 7, 2022

Update plugin-typings or add error?: boolean; to the index.d.ts file.


Pedro8
  • Author
  • 9 replies
  • July 7, 2022

Update plugin-typings as suggested by @tank666 makes it work with error field, thanks man!


Ryba
  • 9 replies
  • January 10, 2023

Did you actually manage to close error message after timeout? For me, it looks like timeout is being ignored for error messages and they need to be closed by the user.


tank666
  • 4863 replies
  • January 29, 2023

@Ryba, Figma has fixed this and now the error notification will close after a timeout.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings