Property 'fontName' does not exist on type 'BaseStyle'

Hello all,

I have this typescript error, but i am not sure what is mean, and how to resolve it. Any help would be appreciated. Thanks

Did you mean to use getRangeTextStyleId instead from a TextNode?

Hello Nelson,
Thanks for the reply.

I want the property of the entire TextNode and not on character set of that TextNode.

So what i did was to find all TexT Styles and then compare their Property to other element. What is confusing me its that everything is working as intended, but im still having this typescript error/warning message.

Is their any information on BaseStyle Type or why it might say that the property does not exist on it while in fact it does return something?

Ah, thanks for the clarification. The good news is that if your code works, it’s fine. That’s because your TypeScript gets compiled into JavaScript. So the error you see doesn’t exist in JS.

TypeScript is designed for syntax and type checking, so that warning appears because it thinks you are sending it a BaseStyle but you know (correctly) that it’s a TextStyle.

To make this error go away, just cast it explicitly as a TextStyle, e.g.

const aTextStyleFontFamily = (figma.getStyleById(id) as TextStyle)

1 Like
1 Like

Thank again for taking the time to answer. It is really helpful and explicitly asserting the time fixed the error :grinning:

Hi Gleb, thank you for the detail answer. Really appreciated it