-
Notifications
You must be signed in to change notification settings - Fork 430
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
Export Type declarations for turbo:
events
#452
Conversation
7d3b397
to
cf65909
Compare
TurboBeforeCacheEvent, | ||
TurboBeforeRenderEvent, | ||
TurboBeforeVisitEvent, | ||
TurboClickEvent, |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even export them without the Turbo
prefix? FrameElement
and StreamElement
don't have it.
6c9b740
to
df3ad64
Compare
13ef36d
to
b1a5b44
Compare
Want to rebase this @seanpdoyle? |
b9bfd7f
to
17bf33c
Compare
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
* 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)
Various
turbo:
-prefixed events are dispatched as CustomEventinstances with data encoded into the detail property.
In TypeScript, that property is encoded as
any
, but theCustomEvent
type is generic (i.e.
CustomEvent<T>
) where the generic Type argumentdescribes the structure of the
detail
key.This commit introduces types that extend from
CustomEvent
for eachevent, 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.