mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for simulant (#41638)
This commit is contained in:
parent
970dc8fea8
commit
ebc4c80b7d
14
types/simulant/index.d.ts
vendored
Normal file
14
types/simulant/index.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// Type definitions for simulant 0.2
|
||||
// Project: https://github.com/Rich-Harris/simulant#readme
|
||||
// Definitions by: Elizabeth Craig <https://github.com/ecraig12345>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace event {
|
||||
function fire(el: Node, e: Event): void;
|
||||
function fire(el: Node, e: string, payload?: { [key: string]: any }): void;
|
||||
}
|
||||
|
||||
declare function event(eventName: string, payload?: { [key: string]: any }): Event;
|
||||
declare function event(window: Window, eventName: string, payload?: { [key: string]: any }): Event;
|
||||
|
||||
export = event;
|
||||
16
types/simulant/simulant-tests.ts
Normal file
16
types/simulant/simulant-tests.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import * as simulant from 'simulant';
|
||||
|
||||
simulant(window, 'click'); // $ExpectType Event
|
||||
simulant(window, 'click', { foo: 'bar' }); // $ExpectType Event
|
||||
|
||||
simulant('click'); // $ExpectType Event
|
||||
simulant('click', { foo: 'bar' }); // $ExpectType Event
|
||||
|
||||
const div = document.createElement('div');
|
||||
|
||||
simulant.fire(document, new MouseEvent('click')); // $ExpectType void
|
||||
simulant.fire(div, new MouseEvent('click')); // $ExpectType void
|
||||
|
||||
simulant.fire(document, 'click'); // $ExpectType void
|
||||
simulant.fire(div, 'click'); // $ExpectType void
|
||||
simulant.fire(div, 'click', { foo: 'bar' }); // $ExpectType void
|
||||
24
types/simulant/tsconfig.json
Normal file
24
types/simulant/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",
|
||||
"simulant-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/simulant/tslint.json
Normal file
1
types/simulant/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user