Skip to content

Example from README gives TypeScript error #554

@philwolstenholme

Description

@philwolstenholme

Hi, thanks for all your work on this package :)

I might have found a documentation issue or perhaps a bug?

Copying this from the examples in the README:

<Feature name="v2">
  {(isEnabled: boolean) =>
    isEnabled ? <h1>My App v2</h1> : <h1>My App v1</h1>
  }
</Feature>;

Gives me this TypeScript warning:

Type '(isEnabled: boolean) => JSX.Element' is not assignable to type 'ReactNode | ((hasFeature: boolean | FeatureGroup) => Element)'.
  Type '(isEnabled: boolean) => JSX.Element' is not assignable to type '(hasFeature: boolean | FeatureGroup) => Element'.
    Types of parameters 'isEnabled' and 'hasFeature' are incompatible.
      Type 'boolean | FeatureGroup' is not assignable to type 'boolean'.
        Type 'FeatureGroup' is not assignable to type 'boolean'.ts(2322)

My TS skills aren't good enough to debug this myself but I got the sense that perhaps a feature may have been added since the examples were added?

This gives no warning, but I'm not sure I'm handling the possibility of isEnabled being a FeatureGroup here:

<Feature name="v2">
  {(isEnabled) => (isEnabled ? <h1>My App v2</h1> : <h1>My App v1</h1>)}
</Feature>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions