Skip to main content
Question

I'm trying to load the font but getting this error

  • March 14, 2024
  • 6 replies
  • 380 views

Neha_Gupta1

Error
Argument of type 'FontName | unique symbol' is not assignable to parameter of type 'FontName'. Type 'typeof figma.mixed' is not assignable to type 'FontName'.ts(2345)

Here’s my code.

  (async () => {

    const text = figma.createText()
    await figma.loadFontAsync(text.fontName)

    text.characters = link
  
  })()
This topic has been closed for replies.

6 replies

tank666
  • March 14, 2024

There is no Plugin API bug here. This code works as expected and you can check it yourself (just run the plugin with this code). You are getting this Typescript error only in your IDE. I can’t tell you for sure because I don’t use Typescript, but it looks like you should follow the rules and syntax of that language.


user_of_figma

Usual arrow. I just used type conversion 🙂 as FontName


user_of_figma

I just used type conversion : ) as FontName


Neha_Gupta1
  • Author
  • New Member
  • March 14, 2024

@tank666

First of all, I’m using the IDE recommended by Figma.

Secondly, I picked the code exactly from Figma’s API docs, I’m sure there’s no syntax error there.

Thirdly, I did run the plugin, it’s not working.


Neha_Gupta1
  • Author
  • New Member
  • March 14, 2024

@user_of_figma_mikita
I ended up doing that and it worked. Thanks ❤️❤️


tank666
  • March 15, 2024

As I said, this code works as expected.