mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 05:20:25 +00:00
Types for "micro-events" package (#31718)
* Types for "micro-events" package * Fix version of TS by travis error
This commit is contained in:
committed by
Wesley Wigham
parent
eca1d0fcdb
commit
052b473238
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for micro-events 1.0
|
||||
// Project: https://github.com/alexanderGugel/micro-events
|
||||
// Definitions by: Alexander Sychev <https://github.com/AlexanderSychev>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/** Event emitter class */
|
||||
declare class MicroEventEmitter {
|
||||
/** Max listeners count */
|
||||
maxListeners: number;
|
||||
/** Attach listener */
|
||||
on(type: string, handler: MicroEventEmitter.EventHandler): MicroEventEmitter;
|
||||
/** Detach listener */
|
||||
off(type: string, handler?: MicroEventEmitter.EventHandler): MicroEventEmitter;
|
||||
/** Trigger event */
|
||||
emit(type: string, ...arguments: any[]): MicroEventEmitter;
|
||||
}
|
||||
declare namespace MicroEventEmitter {
|
||||
/** Event handler function signature */
|
||||
type EventHandler = (...args: any[]) => any;
|
||||
}
|
||||
export = MicroEventEmitter;
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as EventEmitter from "micro-events";
|
||||
|
||||
const myEventEmitter = new EventEmitter();
|
||||
|
||||
myEventEmitter.maxListeners; // $ExpectType number
|
||||
|
||||
const listener = (first: string) => {};
|
||||
|
||||
myEventEmitter.on('foo', listener); // $ExpectType MicroEventEmitter
|
||||
|
||||
myEventEmitter.emit('foo', 'bar'); // $ExpectType MicroEventEmitter
|
||||
|
||||
myEventEmitter.off('foo', listener); // $ExpectType MicroEventEmitter
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"micro-events-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user