-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export Mitt types for TS consumers (#101)
* Export Mitt types for TS consumers * Add rudimentary tests for exported TS types * Run tests against the generated output instead of src
- Loading branch information
1 parent
59cc3d1
commit eb2be7c
Showing
5 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import mitt, { EventHandlerList, EventHandlerMap } from '..'; | ||
|
||
const events = mitt(); | ||
function foo() {} | ||
events.on('foo', foo); | ||
events.emit('foo', 'hello'); | ||
|
||
// handler return type should be ignored: | ||
events.on('foo', async e => e * 42); | ||
|
||
// event map type | ||
const map = new Map<string, EventHandlerList>([ | ||
['foo', [foo]] | ||
]); | ||
const events2 = mitt(map); | ||
events2.emit('foo', 'hello'); | ||
|
||
// event map type & iterables | ||
const map2 : EventHandlerMap = new Map(Object.entries(({ foo: [foo] }))); | ||
mitt(map2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compileOnSave": false, | ||
"compilerOptions": { | ||
"noEmit": true, | ||
"declaration": true, | ||
"moduleResolution": "node" | ||
}, | ||
"exclude": [ | ||
"test" | ||
] | ||
} |