mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Added types for dush (#36146)
This commit is contained in:
parent
79f6b71c16
commit
f7e00e2fb3
9
types/dush/dush-tests.ts
Normal file
9
types/dush/dush-tests.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import dush = require('dush');
|
||||
|
||||
const emitter = dush(); // $ExpectType Emitter
|
||||
|
||||
emitter // $ExpectType Emitter
|
||||
.on('hi', place => console.log(`hello ${place}!`))
|
||||
.on('hi', place => console.log(`hi ${place}, yeah!`));
|
||||
|
||||
emitter.emit('hi', 'world'); // $ExpectType Emitter
|
||||
28
types/dush/index.d.ts
vendored
Normal file
28
types/dush/index.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Type definitions for dush 3.0
|
||||
// Project: https://github.com/tunnckocore/dush#readme
|
||||
// Definitions by: andrycodestuffs <https://github.com/andrycodestuffs>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
declare var dush: dush.DushStatic;
|
||||
|
||||
declare namespace dush {
|
||||
type Handler = (...event: any[]) => void;
|
||||
type WildcardHandler = (type?: string, ...event: any[]) => void;
|
||||
|
||||
interface DushStatic {
|
||||
(): Emitter;
|
||||
}
|
||||
|
||||
interface Emitter {
|
||||
_allEvents: Array<{ [eventName: string]: Handler[] }>;
|
||||
use: (plugin: (app: Emitter, options: any) => void, options?: any) => Emitter;
|
||||
on(type: string, handler: Handler): Emitter;
|
||||
on(type: "*", handler: WildcardHandler): Emitter;
|
||||
once(type: string, handler: Handler): Emitter;
|
||||
once(type: "*", handler: WildcardHandler): Emitter;
|
||||
off(type: string, handler?: Handler): Emitter;
|
||||
off(type: "*", handler?: WildcardHandler): Emitter;
|
||||
emit(type: string, ...event: any[]): Emitter;
|
||||
}
|
||||
}
|
||||
|
||||
export = dush;
|
||||
24
types/dush/tsconfig.json
Normal file
24
types/dush/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dush-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/dush/tslint.json
Normal file
1
types/dush/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user