diff --git a/index.d.ts b/index.d.ts
index 9203568..fe27037 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -1,13 +1,11 @@
-///
-
-import * as EventEmitter from 'events'
+import Nanobus = require('nanobus')
export = Choo
declare class Choo {
constructor (opts?: Choo.IChoo)
- use (callback: (state: Choo.IState, emitter: EventEmitter, app: this) => void): void
- route (routeName: string, handler: (state: Choo.IState, emit: (name: string, ...args: any[]) => void) => void): void
+ use (callback: (state: Choo.IState, emitter: Nanobus, app: this) => void): void
+ route (routeName: string, handler: (state: Choo.IState, emit: Nanobus['emit']) => void): void
mount (selector: string): void
start (): HTMLElement
toString (location: string, state?: Choo.IState): string
@@ -18,6 +16,12 @@ declare namespace Choo {
history?: boolean
href?: boolean
hash?: boolean
+ cache?: number | ICache
+ }
+
+ export interface ICache {
+ get(id: string | number): undefined | null | any
+ set(id: string | number, element: any): void
}
export interface IState {
diff --git a/index.test-d.ts b/index.test-d.ts
new file mode 100644
index 0000000..f024049
--- /dev/null
+++ b/index.test-d.ts
@@ -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(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