launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
81 stars 67 forks source link

fix: improve types of withLDProvider #97

Closed dsifford closed 2 years ago

dsifford commented 2 years ago

Requirements

Related issues

N/A

Describe the solution you've provided

Currently, the way that the withLDProvider function is implemented, end-users are unable to supply prop types for the wrapped component. This results in the type of the wrapped component to always be React.ComponentType<{}> which causes errors when the component is actually expected to have props.

This change makes the withLDProvider a generic function that end-users can supply props to.

Describe alternatives you've considered

There are no alternatives that I'm aware of.

Additional context

Ran into this issue in our codebase this afternoon. Pushing out a fix for this would be greatly appreciated.

dsifford commented 2 years ago

Whoops, sorry about that...

I think you might have two competing formatters or something. I noticed when I was working on this that prettier didn't seem to agree with tslint.

Should be good to go now.

dsifford commented 2 years ago

@bwoskow-ld I am not seeing the same errors when I run lint:all

image

I went ahead and just added a new line at the end of the file (which I think is what the second error is that you're showing) but i did not address the error stemming from an unsafe expression because I did not touch that code.

dsifford commented 2 years ago

@bwoskow-ld Actually, I did not add a trailing new line at the end of the file because that triggers lint errors if I do.

image

How do you suggest we proceed here? We have breaking issues in our production code because of this that we have to now use @ts-ignore on for the time being.

bwoskow-ld commented 2 years ago

Thanks for pointing out the fact that the remaining lint issues weren't relating to your changes. That got me thinking that maybe the issue was on my end, which it was -- my linter wasn't using my intended configuration. To verify this I temporarily pushed your changes such that we could build them on our CircleCI account and they passed.

With that in mind, I'll take it from here and get you a release 😄

bwoskow-ld commented 2 years ago

This is now available in 2.23.2.