launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
86 stars 68 forks source link

TS2559: Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes'. #223

Open kjsalexander opened 10 months ago

kjsalexander commented 10 months ago

Is this a support request? No

Describe the bug The type declaration of withLDProvider throws TS errors about not having anything in common with IntrinsicAttributes. Looking at the source code, it defaults the type to an empty object. If this empty object default is removed, the function runs without any type errors. withLDProvider<T extends JSX.IntrinsicAttributes = {}> should just be withLDProvider<T extends JSX.IntrinsicAttributes>

To reproduce

const Providers = () => {return (<></>)};

export default withLDProvider(launchDarklyConfig)(Providers as React.ComponentType<{}>);
ReactDOM.render(
  <React.StrictMode>
      <Providers>
        <App />
      </Providers>
  </React.StrictMode>,
  document.getElementById("root")
);

Expected behavior Calling withLDProvider should not throw TS errors, and the app should pass types tests

Logs error TS2559: Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes'.

SDK version 3.0.9

Language version, developer tools React 18.2.0 React Dom 18.2.0 Typescript 5.2.2 @types/react 18.2.14 @types/react-dom 18.2.0

OS/platform macOS Monterey Version 12.6 Also occurs for my team members on various versions of macOS

Additional Context There was a similar issue opened with version 2.25 of this client when combined with React 18, I'm not sure if that update was missed in version 3 or if this is a different issue. https://github.com/launchdarkly/react-client-sdk/issues/129

louis-launchdarkly commented 10 months ago

Hello @kjsalexander, thank you for reporting the issue, we will look into this and report back.

Filed internally as 224099.