code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

[1.2.0] type for render prop in figma.boolean is incorrectly inferred as `{}`

Open andrew-pledge-io opened this issue 1 year ago • 3 comments

Given a figma connect configuration where figma.boolean is returning a function in one branch, e.g.:

import figma from '@figma/code-connect';

import { MyComponent } from './MyComponent.js';

figma.connect(MyComponent, 'https://www.figma.com/', {
  props: {
    render: figma.boolean('has a render prop', {
      true: (props: any) => <span {...props}>a render prop</span>,
      false: undefined,
    }),
  },
  example: (props) => <MyComponent render={props.render} />,
});

The type of props.render is {} which results in a type error:

  Type '{}' is not assignable to type '(props: unknown) => ReactNode'.
    Type '{}' provides no match for the signature '(props: unknown): ReactNode'.

In 1.1.4 the type was correctly inferred so this seems to be a regression.

andrew-pledge-io avatar Oct 24 '24 10:10 andrew-pledge-io

Hey @andrew-pledge-io, thanks for the report. Sounds like a bug. We'll look into this and update you!

tomduncalf-figma avatar Oct 24 '24 13:10 tomduncalf-figma

I see a note in the release notes for 1.2.4:

(from 1.2.3) Fix issue with nesting figma.boolean and getProps

Unfortunately it doesn't seem to fix this issue

andrew-pledge-io avatar Dec 18 '24 14:12 andrew-pledge-io

Hi @andrew-pledge-io, that fix was for an unrelated issue, however in the upcoming release (1.2.5) this type issue should be fixed. 1.2.5 will be released sometime after the holidays.

karlpetersson avatar Dec 20 '24 14:12 karlpetersson