delegated-events: Provides its own types (#39628)

This commit is contained in:
Alexander T
2019-10-28 21:15:05 -07:00
committed by Jesse Trinity
parent be990a923f
commit 4eee6080af
5 changed files with 6 additions and 81 deletions
+6
View File
@@ -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
}
-27
View File
@@ -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;
-24
View File
@@ -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
View File
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }