Export Type declarations for turbo: events#452
Merged
dhh merged 1 commit intohotwired:mainfrom Jul 15, 2022
Merged
Conversation
7d3b397 to
cf65909
Compare
seanpdoyle
commented
Nov 18, 2021
| TurboBeforeCacheEvent, | ||
| TurboBeforeRenderEvent, | ||
| TurboBeforeVisitEvent, | ||
| TurboClickEvent, |
Contributor
Author
There was a problem hiding this comment.
I'm not sure what would be better: BeforeCacheEvent, BeforeRenderEvent, etc internally and exporting them here as Turbo-prefixed versions, or sticking with the current style of qualifying them with Turbo.
There was a problem hiding this comment.
Or even export them without the Turbo prefix? FrameElement and StreamElement don't have it.
6c9b740 to
df3ad64
Compare
13ef36d to
b1a5b44
Compare
Member
|
Want to rebase this @seanpdoyle? |
b9bfd7f to
17bf33c
Compare
Member
|
Seems like a legit test failure. |
3ec5201 to
be23945
Compare
Various `turbo:`-prefixed events are dispatched as [CustomEvent][] instances with data encoded into the [detail][] property. In TypeScript, that property is encoded as `any`, but the `CustomEvent` type is generic (i.e. `CustomEvent<T>`) where the generic Type argument describes the structure of the `detail` key. This commit introduces types that extend from `CustomEvent` for each event, and exports them from `/core/index.ts`, which is exported from `/index.ts` in-turn. In practice, there are no changes to the implementation. However, TypeScript consumers of the package can import the types. At the same time, the internal implementation can depend on the types to ensure consistency throughout. [CustomEvent]: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent [detail]: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail
be23945 to
734a7a8
Compare
dhh
pushed a commit
to feliperaul/turbo
that referenced
this pull request
Jul 16, 2022
* main: Allow frames to scroll smoothly into view (hotwired#607) Export Type declarations for `turbo:` events (hotwired#452) Add .php as a valid isHTML extension (hotwired#629) Add original click event to 'turbo:click' details (hotwired#611) Drive Browser tests with `playwright` (hotwired#609) Allow Turbo Streams w/ GET via `data-turbo-stream` (hotwired#612) Only update history when Turbo visit is renderable (hotwired#601) Support development ChromeDriver version overrides (hotwired#606) Turbo stream source (hotwired#415) Expose Frame load state via `[complete]` attribute (hotwired#487) fix(ie/edge): form.method='delete', raises Invalid argument. (hotwired#586) Do not declare global types/constants (hotwired#524) Defensively create custom turbo elements (hotwired#483) Use `replaceChildren` in StreamActions.update (hotwired#534)
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.
Various
turbo:-prefixed events are dispatched as CustomEventinstances with data encoded into the detail property.
In TypeScript, that property is encoded as
any, but theCustomEventtype is generic (i.e.
CustomEvent<T>) where the generic Type argumentdescribes the structure of the
detailkey.This commit introduces types that extend from
CustomEventfor eachevent, and exports them from
/core/index.ts, which is exported from/index.tsin-turn.In practice, there are no changes to the implementation. However,
TypeScript consumers of the package can import the types. At the same
time, the internal implementation can depend on the types to ensure
consistency throughout.