From 10f5d0629f647531300b9311545f0369a04c1d04 Mon Sep 17 00:00:00 2001 From: Kaoru Hagihara Date: Mon, 1 Feb 2016 19:57:52 +0900 Subject: [PATCH] add typescript definition file --- index.d.ts | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ index.js | 6 ++++- tsconfig.json | 25 ++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 index.d.ts create mode 100644 tsconfig.json diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..0cdde52 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,65 @@ +export interface PropOption { + type?: { (...args: any[]): any; }; + required?: boolean; + default?: any; + twoWay?: boolean; + validator?: (value: any) => boolean; + coerce?: (value: any) => any; +} + +export interface WatchOption { + handler(val: any, oldVal: any): void; + deep?: boolean; + immidiate?: boolean; +} + +export interface DirectiveOption { + bind?(): any; + update?(newVal?: any, oldVal?: any): any; + unbind?(): any; + params?: string[]; + deep?: boolean; + twoWay?: boolean; + acceptStatement?: boolean; + priority?: boolean; + [key: string]: any; +} + +export interface FilterOption { + read?: Function; + write?: Function; +} + +export interface TransitionOption { + css?: boolean; + beforeEnter?(el: HTMLElement): void; + enter?(el: HTMLElement, done?: () => void): void; + afterEnter?(el: HTMLElement): void; + enterCancelled?(el: HTMLElement): void; + beforeLeave?(el: HTMLElement): void; + leave?(el: HTMLElement, done?: () => void): void; + afterLeave?(el: HTMLElement): void; + leaveCancelled?(el: HTMLElement): void; + stagger?(index: number): number; +} + +export interface ComponentOption { + props?: string[] | { [key: string]: (PropOption | { new (...args: any[]): any; }) }; + watch?: { [key: string]: ((val: any, oldVal: any) => void) | string | WatchOption }; + template?: string; + directives?: { [key: string]: (DirectiveOption | Function) }; + elementDirectives?: { [key: string]: (DirectiveOption | Function) }; + filters?: { [key: string]: (Function | FilterOption) }; + components?: { [key: string]: any }; + transitions?: { [key: string]: TransitionOption }; + partials?: { [key: string]: string }; + parent?: any; + events?: { [key: string]: ((...args: any[]) => (boolean | void)) | string }; + mixins?: ComponentOption[]; + name?: string; + [key: string]: any; +} + +declare var decorator: (options: ComponentOption) => ClassDecorator; + +export default decorator; diff --git a/index.js b/index.js index 6f60fa5..bb1e164 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,7 @@ +Object.defineProperty(exports, '__esModule', { + value: true +}) + var Vue = require('vue') var internalHooks = [ @@ -60,4 +64,4 @@ function decorator (options) { } } -module.exports = decorator +exports.default = decorator diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..424ff5e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "isolatedModules": false, + "jsx": "react", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "declaration": true, + "noImplicitAny": true, + "removeComments": true, + "noLib": false, + "preserveConstEnums": true, + "suppressImplicitAnyIndexErrors": true + }, + "exclude": [ + "node_modules" + ], + "compileOnSave": false, + "buildOnSave": false, + "atom": { + "rewriteTsconfig": false + } +}