-
Notifications
You must be signed in to change notification settings - Fork 25
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
HTMLElementTagNameMap Part 2 - add create mapping and checker script #5139
HTMLElementTagNameMap Part 2 - add create mapping and checker script #5139
Conversation
Thanks for the PR! 🎉 We've deployed an automatic preview for this PR - you can see your changes here:
Note The build needs to finish before your changes are deployed. |
type LitElementConstructor = Constructor<{}>; | ||
type LitElementClassType = Constructor<{}>; | ||
type ReactiveElementConstructor = Constructor<{}>; | ||
type ReactiveElementClassType = Constructor<{}>; |
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.
Typing all the template types to Constructor<{}>
so that the errors are pushed to the check-html-element-tag-types.ts file
"strictFunctionTypes": false, | ||
"moduleResolution": "bundler", | ||
"maxNodeModuleJsDepth": 3, | ||
"skipLibCheck": true |
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.
Skip errors in *.d.ts
files
"strict": true, | ||
"strictFunctionTypes": false, | ||
"moduleResolution": "bundler", | ||
"maxNodeModuleJsDepth": 3, |
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.
Need this to include the localize mixin from intl: https://github.com/BrightspaceUI/intl/blob/main/lib/localize.js#L17
@@ -0,0 +1,14 @@ | |||
/** Generated from {@link ../tools/create-mapping.sh} */ | |||
import { LitElement } from 'lit'; |
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.
This import is needed to extend the HTMLElementTagNameMap instead of defining it. Not sure if there is a better way to do this.
0c76e6c
to
6acaee2
Compare
jsconfig.json
Outdated
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.
jsconfig.json is something that IDEs will pick up and use to add typing information.
declare global { | ||
interface HTMLElementTagNameMap { | ||
// Components with export class...extends LitElement | ||
'd2l-build-info': import('../index.js').BuildInfo; |
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.
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.
After this, a CI step can be created to automatically update the mapping as needed. Then, adding new components to the map should be very simple. Just add an export or @typedef
, then a PR will automatically be created to add it, and the lint step will ensure that the mixins are being used correctly.
05e2774
to
77821e9
Compare
a2eb685
to
ce2d1ac
Compare
35524ca
to
32c0149
Compare
PR #5190 created to update mapping.d.ts. |
b7c8c0e
to
90ad388
Compare
PR #5215 created to update mapping.d.ts. See https://github.com/BrightspaceUI/core?tab=readme-ov-file#mappingdts-troubleshooting for troubleshooting errors |
90ad388
to
f1d225a
Compare
PR #5220 created to update mapping.d.ts. See https://github.com/BrightspaceUI/core?tab=readme-ov-file#mappingdts-troubleshooting for troubleshooting errors |
f1d225a
to
1d532ee
Compare
PR #5227 created to update mapping.d.ts. See https://github.com/BrightspaceUI/core?tab=readme-ov-file#mappingdts-troubleshooting for troubleshooting errors |
e791355
to
4516b1a
Compare
4516b1a
to
1b73b1b
Compare
Closing, as the usefulness of HtmlElementTagNameMap is not very great, and adds a higher maintenance load on Nimbus |
This adds the ability to include a mappings.d.ts file, which allows an IDE with
lit-ts-plugin
installed to have typings for basic querySelector calls, and getElementByTagName calls. This also allows a project that is using typescript to type the core elements by referencing the mapped typeSee https://github.com/BrightspaceUI/core/pull/5187/files#diff-cbc0e7a7d8e718c3c30b3003face1bc0bcfe98dcd79f3e4024fd270bda4c71d6 for what the final result should look like.
Also see
#5141
#5140