Skip to content

Commit ef53fc4

Browse files
committed
improve types by using interfaces where recommended
1 parent 8d44314 commit ef53fc4

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ryupold/vode",
3-
"version": "1.6.7",
3+
"version": "1.6.8",
44
"description": "a minimalist web framework",
55
"author": "Michael Scherbakow (ryupold)",
66
"license": "MIT",

src/vode.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ export type Effect<S> =
2727

2828
export type EventFunction<S> = (state: S, evt: Event) => Patch<S>;
2929

30-
export type Props<S> = Partial<
30+
export interface Props<S> extends Partial<
3131
Omit<HTMLElement,
3232
keyof (DocumentFragment & ElementCSSInlineStyle & GlobalEventHandlers)> &
3333
{ [K in keyof EventsMap]: EventFunction<S> | Patch<S> } // all on* events
34-
> & {
34+
> {
3535
[_: string]: unknown,
3636
xmlns?: string | null,
3737
class?: ClassProp,
@@ -60,27 +60,29 @@ export type StyleProp =
6060
| string
6161
| "" | null | undefined; // no style
6262

63-
export type EventsMap =
64-
& { [K in keyof HTMLElementEventMap as `on${K}`]: HTMLElementEventMap[K] }
65-
& { [K in keyof WindowEventMap as `on${K}`]: WindowEventMap[K] }
66-
& { [K in keyof SVGElementEventMap as `on${K}`]: SVGElementEventMap[K] }
67-
& { onsearch: Event };
63+
type EventsMapBase =
64+
& { [K in keyof HTMLElementEventMap as `on${K}`]: HTMLElementEventMap[K] }
65+
& { [K in keyof WindowEventMap as `on${K}`]: WindowEventMap[K] }
66+
& { [K in keyof SVGElementEventMap as `on${K}`]: SVGElementEventMap[K] };
67+
68+
export interface EventsMap extends EventsMapBase {}
6869

6970
export type PropertyValue<S> =
7071
| string | boolean | null | undefined | void
7172
| StyleProp | ClassProp
7273
| Patch<S>;
7374

7475
export type Dispatch<S> = (action: Patch<S>) => void;
75-
export type PatchableState<S = object> = S & { patch: Dispatch<S> };
76+
export interface Patchable<S = object> { patch: Dispatch<S>; }
77+
export type PatchableState<S = object> = S & Patchable<S>;
7678

7779
export const globals = {
7880
currentViewTransition: <ViewTransition | null | undefined>undefined,
7981
requestAnimationFrame: !!window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : ((cb: () => void) => cb()),
8082
startViewTransition: !!document.startViewTransition ? document.startViewTransition.bind(document) : null,
8183
};
8284

83-
export type ContainerNode<S = PatchableState> = HTMLElement & {
85+
export interface ContainerNode<S = PatchableState> extends HTMLElement {
8486
/** the `_vode` property is added to the container in `app()`.
8587
* it contains all necessary stuff for the vode app to function.
8688
* remove the container node to clear vodes resources */

0 commit comments

Comments
 (0)