Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implementation type aliases to make types safe application development easier #1619

Open
jhsware opened this issue Dec 11, 2022 · 2 comments

Comments

@jhsware
Copy link
Contributor

jhsware commented Dec 11, 2022

We have a very, very rich set of types in Inferno and many types have similar names. This can make it hard to pick an appropriate type in application code.

It would be great if we could create a limited set of type aliases with intuitive names that can be used by application developers.

Use case:

  • You want to create a look up dictionary with different components that are resolved at runtime to render a list of various items

What is the correct type for the the component? Is it:

  • IComponent<any, any> | Function
  • Component | Function
  • Component<any> | Inferno.StatelessComponent<any>
  • ComponentType

So a type alias could be:

// Require a Function or Class Component where P is a required set of properties
export type InfernoComponent<P = any> = Component<P> | Inferno.StatelessComponent<P>;

This would save time, encourage type safety and make application code more readable.

@Havunen
Copy link
Member

Havunen commented Dec 20, 2022

Yes this is very legit issue.

This issue origins roots to the fact that Inferno JSX typings are based on React Jsx.

In my opinion it would be awesome if we could provide InfernoJs native typings for JSX too and make all these extra types unnecessary.

I haven't found any easy way to implement that and that is why there are so many types / interfaces for similar things

@Havunen
Copy link
Member

Havunen commented Mar 27, 2023

There is nowdays JSX documentation in typescript compiler site: https://www.typescriptlang.org/docs/handbook/jsx.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants