palantir/blueprint

Typings on PanelStack2 are not working as explain in documentation

Open

#5359 opened on Jun 7, 2022

View on GitHub
 (3 comments) (0 reactions) (0 assignees)TypeScript (20,263 stars) (2,167 forks)batch import
P1Package: coreType: bughelp wanted

Description

Environment

  • Package version(s): core 4.4.1
  • Operating System: MacOS Monterrey 12.3.1
  • Browser name and version: Chrome Version 102.0.5005.61

Code Sandbox

(https://codesandbox.io/s/spring-sun-vomre1?file=/src/App.tsx)

Steps to reproduce

  1. Create a component and add a PanelStack2
  2. Add a custom panel component with his own typing props (e.g: ComponentType) using PanelProps<ComponentType>
  3. Try adding this custom panel as initial panel

Actual behavior

You will face this type error: Type 'PanelProps' is not assignable to type 'PanelProps'.

Expected behavior

Types should be ok as it's following, the docs. I also think it should be ok to define Panel as :

type MainPanelProps = {
  loading: boolean;
};

const MainPanel = (props: PanelProps<MainPanelProps>) => {
  return <div />;
};

Possible solution

🤷‍♂️ Sorry, i have no idea.

Contributor guide