plugin-typings icon indicating copy to clipboard operation
plugin-typings copied to clipboard

Use union type to indicate the getStyleById return type

Open anc95 opened this issue 3 years ago • 0 comments

this change will bring better type experience in bellow case

const style = figma.getStyleById(styleId)

if (style.type === 'TEXT') {
  // TS would infer `style` is `TextStyle` type here
} else if (style.type === 'PAINT') {
  // TS would infer `style` is `GridStyle` type here
}

anc95 avatar Apr 23 '22 05:04 anc95