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

Need non-sealed sealed external interface PromiseLike<out T> #2518

Closed
leerenbo opened this issue Sep 17, 2024 · 6 comments
Closed

Need non-sealed sealed external interface PromiseLike<out T> #2518

leerenbo opened this issue Sep 17, 2024 · 6 comments

Comments

@leerenbo
Copy link
Contributor

leerenbo commented Sep 17, 2024

When writing the wrapper for antd's

A type MessageType extends from PromiseLike whick is sealed.

source:
https://github.com/ant-design/ant-design/blob/aa48a3cf4223a422be9d17f4aed2e9fb3aae1003/components/message/interface.ts#L49C1-L51C2

Can the official wrappers maintain the ability of inheritance relationship like in TypeScript? If an interface is inheritable in TypeScript, then do not add “sealed”.

@turansky
Copy link
Collaborator

Can the official wrappers maintain the ability of inheritance relationship like in TypeScript? If an interface is inheritable in TypeScript, then do not add “sealed”.

Do you mean, that sealed external interfaces don't exist?
Because all TS interfaces are inheritable.

@leerenbo
Copy link
Contributor Author

If all TS interfaces are inheritable,the “sealed” modifier is not needed.

We cannot constrain JavaScript developers. In order to support various types of mappings to the greatest extent, I hope not to use “sealed”.

Without type union, inheritance is used more frequently.

@leerenbo
Copy link
Contributor Author

Some necessary “sealed” can be retained. For example, when it comes to the correctness of compiling KotlinJS to JS. If it is just for “when” type judgment and giving up the correctness of wrapping for JS, I don't think it's worth it.

@turansky
Copy link
Collaborator

If all TS interfaces are inheritable, the “sealed” modifier is not needed.

It doesn't work in common case unfortunately.
Inheritable in TS != inheritors are welcome. For example - ChildNode, ParentNode

JFYI - PromiseLike can't have non-external implementations in current state (because of overrides).

PR is welcome

@turansky
Copy link
Collaborator

Will you create PR?

@leerenbo
Copy link
Contributor Author

I will.

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

No branches or pull requests

2 participants