Refactor JSX types to include a reference to instance type#417
Open
Arlen22 wants to merge 3 commits intozdhxiong:v2from
Open
Refactor JSX types to include a reference to instance type#417Arlen22 wants to merge 3 commits intozdhxiong:v2from
Arlen22 wants to merge 3 commits intozdhxiong:v2from
Conversation
This generates a second jsx.*.d.ts which does two things. - Export the types instead of putting them on global - Include the class instance type via a ref attribute
Removed ref property from IntrinsicAttributes interface since it isn't needed to carry the type across to other definitions.
52d6b69 to
cd0c84d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This generates a second jsx.*.d.ts which does two things.
This allows the type declarations to be used with any custom JSX typing system or any other attribute based types.
It might be surprising that this works, but since multiple interface declarations are combined, TypeScript doesn't care where they're declared and just combines them all, allowing the consumer of a library to fill in the missing definitions. All declarations of an interface must have identical type parameters, allowing them to transfer type information.
If the instance type was the only thing I needed, I could match this to
HTMLElementTagNameMap. But I wanted to use my own list of standard attributes rather than the ones from React, because they aren't quite the same and I'm not using React. I'm also using attributes specifically, not properties.