-
Notifications
You must be signed in to change notification settings - Fork 785
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
feat(compiler): generate component custom event types with HTML target #3296
feat(compiler): generate component custom event types with HTML target #3296
Conversation
I can open a PR to the Stencil docs site to account for these changes, if we agree with the approach and naming of the generated types. |
…eat/custom-event-target
I could see us renaming the generated types to be: |
Discussed with the framework team, only concession is if we could rather export all the generated event interfaces globally, instead of under a namespace. This would make implementations similar to: import { InfiniteScrollCustomEvent } from '@ionic/core';
onInfiniteScroll(ev: InfiniteScrollCustomEvent) {
ev.target.complete();
} I originally opted not to do this, based on the type definition file having everything namespaced or under a module. If we so no risk to exporting the interfaces all top-level, I'd like to make that change. |
@sean-perkins We landed |
@rwaskiewicz Sounds good! I'll rebase and incorporate some of the changes we discussed offline (probably ~ mid next week). I'll reach out if I have questions with the latest 👍 |
This PR has been updated. Unsure if you can re-run failed jobs or if I need to push an empty commit to re-trigger CI. I know we can re-run failed actions in framework, assume it is a contributor permission. |
yeah...must be a contributor permission thing. kicked it back off |
this commit adds a single unit test for the new `generate-event-detail-types` file. this was created to ensure that we codify the fact that the interface generated by this file follows a specific format
@@ -6,20 +6,28 @@ import { updateTypeIdentifierNames } from './stencil-types'; | |||
* Generates the individual event types for all @Event() decorated events in a component | |||
* @param cmpMeta component runtime metadata for a single component | |||
* @param typeImportData locally/imported/globally used type names, which may be used to prevent naming collisions | |||
* @param cmpClassName The pascal cas name of the component class |
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.
* @param cmpClassName The pascal cas name of the component class | |
* @param cmpClassName The pascal cased name of the component class |
@@ -32,6 +40,7 @@ export const generateEventTypes = (cmpMeta: d.ComponentCompilerMeta, typeImportD | |||
*/ | |||
const getEventType = ( | |||
cmpEvent: d.ComponentCompilerEvent, | |||
cmpEventDetailInterface: string, |
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.
Minor, can we add the JSDoc for this new parameter?
this commit fixes type checker errors associated with `StencilTypes.updateTypeIdentifierNames` that were missed in the original implementation. these errors were found while reviewing #3296 by happen-stance. STENCIL-445 has been created to investigate how we can run the type checker on tests more often & catch these errors sooner.
this commit fixes type checker errors associated with `StencilTypes.updateTypeIdentifierNames` that were missed in the original implementation. these errors were found while reviewing #3296 by happen-stance. STENCIL-445 has been created to investigate how we can run the type checker on tests more often & catch these errors sooner.
this commit checks in changes to `test/end-to-end/src/components.d.ts` that are generated starting with 846740f (#3296) we missed this as a result of relying on ci to run the end to end tests for us, rather than ever running them locally. the changes found in this commit were generated by running `npm run test.end-to-end` on the commit immediately preceding this one. to avoid issues like this in the future, stencil-451 has been created and added to the backlog
this commit checks in changes to `test/end-to-end/src/components.d.ts` that are generated starting with 846740f (#3296) we missed this as a result of relying on ci to run the end to end tests for us, rather than ever running them locally. the changes found in this commit were generated by running `npm run test.end-to-end` on the commit immediately preceding this one. to avoid issues like this in the future, stencil-451 has been created and added to the backlog
This is great! Thanks for adding it. Are there docs on how to use it? |
@moshner There aren't any explicit docs. However, if you upgrade to Stencil v2.16.0 and re-compile your project, these types should be autogenerated for you |
Docs would be very helpful. Especially, for anyone who is consuming our web components and need to hook into events. |
This is a great enhancement! Is there a particular reason why |
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm test
) were run locally and passednpm run test.karma.prod
) were run locally and passednpm run prettier
) was run locally and passedPull request type
Please check the type of change your PR introduces:
What is the current behavior?
The generated types for a web components custom event, does not include type definitions for the
target
value.GitHub Issue Number: #3291
What is the new behavior?
components.d.ts
for all web component that have custom events.target
.Does this introduce a breaking change?
Testing
The steps outlined below can apply to any Stencil project, but will outline against Ionic Framework:
/core
project.npm run build
to build Stencilcomponents.d.ts
that there is a new namespace calledComponentEvents
.npm run build
frompackages/react
npm run sync
frompackages/react/test-app
.npm run start
.tsx
files (i.e. App.tsx) to use a web component with a JSX event listener that accesses a custom public method on the web component:complete()
function frominfinite-scroll.tsx
.Other information
Closing #3286 in favor of this PR.