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

Inspiration - add create mapping and checker script #5139

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

Conversation

awikkerink
Copy link
Contributor

No description provided.

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-5139/

Note

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

type LitElementConstructor = Constructor<{}>;
type LitElementClassType = Constructor<{}>;
type ReactiveElementConstructor = Constructor<{}>;
type ReactiveElementClassType = Constructor<{}>;
Copy link
Contributor Author

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
Copy link
Contributor Author

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,
Copy link
Contributor Author

@awikkerink awikkerink Nov 10, 2024

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';
Copy link
Contributor Author

@awikkerink awikkerink Nov 10, 2024

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.

@awikkerink awikkerink force-pushed the awikkerink/inspiration-add-create-mapping-script branch 2 times, most recently from 0c76e6c to 6acaee2 Compare November 13, 2024 15:23
jsconfig.json Outdated
Copy link
Contributor Author

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;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just starting with d2l-build-info as a proof of concept. Once the other PRs: #5140, #5141 are merged, the mapping.d.ts can be rebuilt.

Copy link
Contributor Author

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.

@awikkerink awikkerink force-pushed the awikkerink/inspiration-add-create-mapping-script branch 2 times, most recently from 05e2774 to 77821e9 Compare November 18, 2024 20:25
@awikkerink awikkerink force-pushed the awikkerink/inspiration-add-create-mapping-script branch 2 times, most recently from a2eb685 to ce2d1ac Compare November 21, 2024 15:14
@awikkerink awikkerink force-pushed the awikkerink/inspiration-add-create-mapping-script branch from ce2d1ac to b03db4f Compare November 25, 2024 18:57
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.

1 participant