-
Notifications
You must be signed in to change notification settings - Fork 793
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
fix(types): expose missing JSX.Element
on h
#5944
fix(types): expose missing JSX.Element
on h
#5944
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution ❤️
This reverts commit 958c826.
I see what's going on. So you very much rely on the fact that this returns JSX in TS is incapable (today) of typing the resulting element based on the arguments supplied to JSX. You can only return a static type. You have code like: private getSVGPath(mode: Mode, indeterminate: boolean): HTMLElement {
// simplified function body here
let path = <path d="M6 12L18 12" part="mark" />
return path;
} So the problem is that with the latest version of Stencil this Based on this, I think that Stencil returns native html/svg elements from its JSX factory (unlike most other frameworks). So naturally you'd like to type those as some kind of concrete element types. This is not possible in TS. You either have to type this as Side note: I don't quite understand why this |
Thanks for the clarification @Andarist. I would be happy to merge this PR if it doesn't break Ionic Framework as our upstream project. Do you think this is possible? |
@christian-bromann we could try with: export namespace JSX {
type Element = any;
} This would, at least, match the current behavior. It would be different from |
@Andarist let's try, mind raising a PR for this? |
What is the current behavior?
An accidental
any
can leak as that's what JSX returns whenJSX.Element
is missing (TS playground)GitHub Issue Number: N/A
What is the new behavior?
This PR reuses the already defined
LocalJSX.Element
asJSX.Element
. The resulting type is still pretty permissive (it's an empty interface) but at least it's notany
.Documentation
N/A
Does this introduce a breaking change?
Testing
Manual testing of how types are resolved with this.
Other information
discovered here microsoft/TypeScript#59584 (comment)