Skip to content
This repository was archived by the owner on Sep 2, 2020. It is now read-only.

Event.preventUpdate (suggestion) #1

@danielweck

Description

@danielweck

Hello, thank you for this project :)

I am using the riot-typed package that is currently published on the NPM repository ( https://www.npmjs.com/package/riot-typed ), but instead of using Typings I simply reference your main Riot type definitions from my top-level declarations.d.ts:

/// <reference path="../node_modules/riot-typed/src/riot.d.ts" />

I added this simple extension so that the preventUpdate property (which RiotJS attaches to DOM events) is typed properly:

declare interface RiotEvent extends Event {
    preventUpdate: boolean;
}

Say I have the following Riot Tag specification:

<riot-mytag>
  <button onclick="{ onclickButton }">butt</button>
</riot-mytag>

...I can then use the RiotEvent in place of MouseEvent (or more generally, lib.dom.Event):

    // 'this' type is RiotTag
    this.onclickButton = (ev: RiotEvent) => {
        console.log("CLICK button");

        ev.preventUpdate = true;
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions