mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
delegated-events: Provides its own types (#39628)
This commit is contained in:
committed by
Jesse Trinity
parent
be990a923f
commit
4eee6080af
@@ -756,6 +756,12 @@
|
||||
"sourceRepoURL": "https://github.com/sindresorhus/delay",
|
||||
"asOfVersion": "3.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "delegated-events",
|
||||
"typingsPackageName": "delegated-events",
|
||||
"sourceRepoURL": "https://github.com/dgraham/delegated-events#readme",
|
||||
"asOfVersion": "1.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "detect-browser",
|
||||
"typingsPackageName": "detect-browser",
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
// Tests are re-used based on `delegated-events`'s flow tests.
|
||||
// https://github.com/dgraham/delegated-events/blob/master/test/test-flow.js
|
||||
|
||||
import { on, off, fire } from "delegated-events";
|
||||
|
||||
function onButtonClick(event: Event) {
|
||||
event.target;
|
||||
}
|
||||
|
||||
on("click"); // $ExpectError
|
||||
on("click", ".js-button"); // $ExpectError
|
||||
on("click", ".js-button", onButtonClick); // $ExpectType void
|
||||
|
||||
off("click"); // $ExpectError
|
||||
off("click", ".js-button"); // $ExpectError
|
||||
off("click", ".js-button", onButtonClick); // $ExpectType void
|
||||
|
||||
// $ExpectType void
|
||||
on("robot:singularity", ".js-robot-image", (event: Event) => {
|
||||
event.target;
|
||||
});
|
||||
|
||||
const image = document.querySelector(".js-button");
|
||||
|
||||
if (image) {
|
||||
fire(image); // $ExpectError
|
||||
fire(image, "robot:singularity"); // $ExpectType boolean
|
||||
fire(image, "robot:singularity", { name: "Hubot" }); // $ExpectType boolean
|
||||
}
|
||||
Vendored
-27
@@ -1,27 +0,0 @@
|
||||
// Type definitions for delegated-events 1.0
|
||||
// Project: https://github.com/dgraham/delegated-events#readme
|
||||
// Definitions by: Christopher Parsons <https://github.com/cwparsons>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Definitions based on the projects' flow definitions.
|
||||
// https://github.com/dgraham/delegated-events/blob/master/delegated-events.js.flow
|
||||
|
||||
export interface EventListenerOptions {
|
||||
capture?: boolean;
|
||||
}
|
||||
|
||||
export function on(
|
||||
name: string,
|
||||
selector: string,
|
||||
handler: EventListenerOrEventListenerObject,
|
||||
options?: EventListenerOptions
|
||||
): void;
|
||||
|
||||
export function off(
|
||||
name: string,
|
||||
selector: string,
|
||||
handler: EventListenerOrEventListenerObject,
|
||||
options?: EventListenerOptions
|
||||
): void;
|
||||
|
||||
export function fire(target: EventTarget, name: string, detail?: any): boolean;
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"delegated-events-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user