Type improvements (#706)

* use nanobus for the emitter typings

instead of `events`, which is a bit different

* add typings for `cache` option
This commit is contained in:
Renée Kooi
2020-01-23 18:11:06 +01:00
committed by GitHub
parent 2d56f305e0
commit 2893de86d0
3 changed files with 61 additions and 9 deletions
Vendored
+9 -5
View File
@@ -1,13 +1,11 @@
/// <reference types="node" />
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 {