Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c870cee

Browse files
committed
Explicitly type Controller.dispatch() method
1 parent eedb8ed commit c870cee

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/core/controller.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import { ValuePropertiesBlessing, ValueDefinitionMap } from "./value_properties"
88

99
export type ControllerConstructor = Constructor<Controller>
1010

11+
type DispatchOptions = Partial<{
12+
target: Element | Window | Document
13+
detail: Object
14+
prefix: string
15+
bubbles: boolean
16+
cancelable: boolean
17+
}>
18+
1119
export class Controller<ElementType extends Element = Element> {
1220
static blessings = [
1321
ClassPropertiesBlessing,
@@ -79,7 +87,13 @@ export class Controller<ElementType extends Element = Element> {
7987

8088
dispatch(
8189
eventName: string,
82-
{ target = this.element, detail = {}, prefix = this.identifier, bubbles = true, cancelable = true } = {}
90+
{
91+
target = this.element,
92+
detail = {},
93+
prefix = this.identifier,
94+
bubbles = true,
95+
cancelable = true,
96+
}: DispatchOptions = {}
8397
) {
8498
const type = prefix ? `${prefix}:${eventName}` : eventName
8599
const event = new CustomEvent(type, { detail, bubbles, cancelable })

0 commit comments

Comments
 (0)