Skip to content

Commit 0f4e8f0

Browse files
davidkpianodevelopit
authored andcommitted
Fixing TypeScript usage. Fixes #60 (#67)
* Fixing TypeScript usage * Removing extraneous formatting
1 parent 820ac6a commit 0f4e8f0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ You can find the library on `window.mitt`.
5757
```js
5858
import mitt from 'mitt'
5959

60-
let emitter = mitt()
60+
const emitter = mitt()
6161

6262
// listen to an event
6363
emitter.on('foo', e => console.log('foo', e) )
@@ -77,8 +77,8 @@ emitter.off('foo', onFoo) // unlisten
7777
### Typescript
7878

7979
```ts
80-
import * as mitt from 'mitt';
81-
let emitter: mitt.Emitter = new mitt();
80+
import mitt from 'mitt';
81+
const emitter: mitt.Emitter = mitt();
8282
```
8383

8484
## Examples & Demos

mitt.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@ declare namespace mitt {
88
type Handler = (event?: any) => void;
99

1010
interface MittStatic {
11-
new(all?: {[key: string]: Handler}): Emitter;
11+
(all?: {[key: string]: Handler}): Emitter;
1212
}
1313

1414
interface Emitter {
1515
/**
1616
* Register an event handler for the given type.
17-
*
17+
*
1818
* @param {string} type Type of event to listen for, or `"*"` for all events.
1919
* @param {Handler} handler Function to call in response to the given event.
20-
*
20+
*
2121
* @memberOf Mitt
2222
*/
2323
on(type: string, handler: Handler): void;
2424

2525
/**
2626
* Function to call in response to the given event
27-
*
27+
*
2828
* @param {string} type Type of event to unregister `handler` from, or `"*"`
2929
* @param {Handler} handler Handler function to remove.
30-
*
30+
*
3131
* @memberOf Mitt
3232
*/
3333
off(type: string, handler: Handler): void;
3434

3535
/**
3636
* Invoke all handlers for the given type.
3737
* If present, `"*"` handlers are invoked prior to type-matched handlers.
38-
*
38+
*
3939
* @param {string} type The event type to invoke
4040
* @param {any} [event] An event object, passed to each handler
41-
*
41+
*
4242
* @memberOf Mitt
4343
*/
4444
emit(type: string, event?: any): void;

0 commit comments

Comments
 (0)