-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use nanobus for the emitter typings instead of `events`, which is a bit different * add typings for `cache` option
- Loading branch information
1 parent
2d56f30
commit 2893de8
Showing
3 changed files
with
61 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { expectAssignable, expectType } from 'tsd' | ||
import Choo = require('.') | ||
|
||
new Choo({}) | ||
new Choo() | ||
|
||
new Choo({ cache: 100 }) | ||
new Choo({ | ||
cache: new Map() | ||
}) | ||
new Choo({ | ||
cache: { | ||
get: (id) => null, | ||
set: (id, value) => expectType<any>(value) | ||
} | ||
}) | ||
|
||
const app = new Choo({ | ||
history: false, | ||
href: true, | ||
}) | ||
|
||
app.use((state, emitter) => { | ||
state.title = 'choo choo' | ||
emitter.on(state.events.DOMCONTENTLOADED, () => { | ||
emitter.emit('example') | ||
}) | ||
}) | ||
|
||
app.route('/', (state, emit) => { | ||
expectAssignable<object>(state.params) | ||
expectType<string>(state.href) | ||
expectType<string>(state.route) | ||
expectType<string>(state.title) | ||
emit('example') | ||
}) | ||
|
||
expectType<string>(app.toString('/')) | ||
|
||
app.mount('body') |
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