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

Typescript JSDoc Part 1 - Add template parameters to mixins #5140

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

awikkerink
Copy link
Contributor

@awikkerink awikkerink commented Nov 10, 2024

This is the trickiest part to automate, but with #5139, it's possible to verify which mixins aren't typed correctly. Basically, the lint check will complain if the mixin doesn't return a type that extends HTMLElement, so an improperly typed mixin will fail the check.

Copy link
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-5140/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @template {ReactiveElementClassType} S
* @param {S} superclass
*/
const InternalSkeletonGroupMixin = superclass => class extends SkeletonMixin(superclass) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Internal mixin constant to avoid unnecessary whitespace changes.

constructor() {
super();
constructor(...args) {
super(...args);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typescript compiler is picky with mixin constructor arguments, and won't type things correctly if ...args are missing.

@awikkerink awikkerink force-pushed the awikkerink/inspiration-add-template-parameters-to-mixins branch from a8cfdb2 to 1bda15f Compare November 13, 2024 15:42
@awikkerink awikkerink force-pushed the awikkerink/inspiration-add-template-parameters-to-mixins branch 3 times, most recently from 36b0f26 to 967d71a Compare November 20, 2024 01:25
@awikkerink awikkerink force-pushed the awikkerink/inspiration-add-template-parameters-to-mixins branch 3 times, most recently from 267f0f5 to 128e003 Compare November 27, 2024 17:54
@awikkerink awikkerink force-pushed the awikkerink/inspiration-add-template-parameters-to-mixins branch from 128e003 to 80789a2 Compare December 1, 2024 03:03
@awikkerink awikkerink marked this pull request as ready for review December 2, 2024 14:10
@awikkerink awikkerink requested a review from a team as a code owner December 2, 2024 14:10
@awikkerink awikkerink changed the title Add template parameters to mixins HTMLElementTagNameMap Part 1 - Add template parameters to mixins Dec 3, 2024
@awikkerink awikkerink force-pushed the awikkerink/inspiration-add-template-parameters-to-mixins branch from 80789a2 to d74be6c Compare December 4, 2024 20:43
* Maintaining a common.d.ts in this repo or elsewhere isn't
  desired
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlockhart would this be something you would want maintained in another repo?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for everything to be in another repo? Ideally a repo like core that isn't TS-aware shouldn't need to have any TS stuff in it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jsdoc stuff being in another repo would be difficult to maintain and would make navigating to the component definitions more difficult.

@dlockhart dlockhart marked this pull request as draft December 17, 2024 14:26
@dlockhart
Copy link
Member

I've converted these to Draft status so we don't get daily notifications about them while the overall TS strategy gets figured out.

@KearseTrevor
Copy link
Contributor

KearseTrevor commented Jan 2, 2025

Hi @awikkerink , I noticed #5139 (comment) and was curious if Part 1 and 3 were also going to get culled under the same logic?

@awikkerink
Copy link
Contributor Author

awikkerink commented Jan 3, 2025

Hi @awikkerink , I noticed #5139 (comment) and was curious if Part 1 and 3 were also going to get culled under the same logic?

No. Typing the mixins and exporting the components is useful for dependents. It also makes putting the HTMLTagElementMap in another repo possible.

@awikkerink
Copy link
Contributor Author

Hi @awikkerink , I noticed #5139 (comment) and was curious if Part 1 and 3 were also going to get culled under the same logic?

No. Typing the mixins and exporting the components is useful for dependents. It also makes putting the HTMLTagElementMap in another repo possible.

Perhaps I should rename the PRs then to make it more clear. My original intention was to add the tag maps, but this added too much complexity and not enough value. But I know the mixin typing will be useful.

@awikkerink awikkerink changed the title HTMLElementTagNameMap Part 1 - Add template parameters to mixins Typescript JSDoc Part 1 - Add template parameters to mixins Jan 3, 2025
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

Successfully merging this pull request may close these issues.

3 participants