From 8615c9b481d5e1009a33de23f4a8dd2020cfcafe Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Thu, 5 Oct 2017 16:51:09 -0400 Subject: [PATCH] Add typescript definition (#545) --- index.d.ts | 38 ++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 39 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..422d3ea --- /dev/null +++ b/index.d.ts @@ -0,0 +1,38 @@ +/// + +import * as EventEmitter from 'events' + +export = Choo + +declare class Choo { + constructor (opts: Choo.IChoo) + use (callback: (state: Choo.IState, emitter: EventEmitter) => void): void + route (routeName: string, handler: (state: Choo.IState, emit: (name: string, ...args: any[]) => void) => void): void + mount (selector: string): void + start (): HTMLElement + toString (location: string, state?: Choo.IState): string +} + +declare namespace Choo { + export interface IChoo { + history?: boolean + href?: boolean + } + + export interface IState { + events: { + [key: string]: string + } + params: { + [key: string]: string + } + query?: { + [key: string]: string + } + href: string + route: string + title: string + [key: string]: any + } +} + diff --git a/package.json b/package.json index fa355ae..996cd87 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "xtend": "^4.0.1" }, "devDependencies": { + "@types/node": "^8.0.20", "browserify": "^14.3.0", "bundle-collapser": "^1.2.1", "dependency-check": "^2.8.0",