From 16cb05c0f69b99cd1468ad6590be64c568366c90 Mon Sep 17 00:00:00 2001 From: odangosan Date: Sun, 21 Dec 2014 13:39:32 +0900 Subject: [PATCH 1/3] Add vue/vue.d.ts,vue/vue-tests.ts --- vue/vue-tests.ts | 29 ++++++++ vue/vue-tests.ts.tscparams | 1 + vue/vue.d.ts | 141 +++++++++++++++++++++++++++++++++++++ vue/vue.d.ts.tscparams | 1 + 4 files changed, 172 insertions(+) create mode 100644 vue/vue-tests.ts create mode 100644 vue/vue-tests.ts.tscparams create mode 100644 vue/vue.d.ts create mode 100644 vue/vue.d.ts.tscparams diff --git a/vue/vue-tests.ts b/vue/vue-tests.ts new file mode 100644 index 000000000..540f9f5ba --- /dev/null +++ b/vue/vue-tests.ts @@ -0,0 +1,29 @@ +/// +module myapp { + "use strict"; + export class Application extends Vue { + constructor() { + super(); + Vue.config.debug = true; + this._init({ + // data is necessary to always write in init() + data: { + text: "hello world." + // }, + // methods : { + // action : this.action + /* same as unser */ + } + }); + this.methods = { + action: this.action + } + } + action(): void { + console.log("action"); + } + } +} + +var app = new myapp.Application(); +app.$mount("#main"); diff --git a/vue/vue-tests.ts.tscparams b/vue/vue-tests.ts.tscparams new file mode 100644 index 000000000..934bc29ef --- /dev/null +++ b/vue/vue-tests.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny \ No newline at end of file diff --git a/vue/vue.d.ts b/vue/vue.d.ts new file mode 100644 index 000000000..471bf1b63 --- /dev/null +++ b/vue/vue.d.ts @@ -0,0 +1,141 @@ +// Type definitions for vuejs 0.11.0 +// Project: https://github.com/yyx990803/vue +// Definitions by: odangosan https://github.com/odangosan +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module vue { + export class Vue { + /** + * The Vue Constructor + * http://vuejs.org/api/index.html + */ + constructor(options?: {}); + + /** + * Options + * http://vuejs.org/api/options.html + */ + // still... + + /** + * Instance Properties + * http://vuejs.org/api/instance-properties.html + */ + $el: HTMLElement; + $data: Object; + $options: Object; + $parent: Vue; + $root: Vue; + $: Object; + $$: Object; + + /** + * Instance Methods + * http://vuejs.org/api/instance-methods.html + */ + /** + * Data + */ + $watch(expression: string, callback: ValueCallback, deep?: boolean, immediate?: boolean): void; + $get(expression: string): any; + $set(keypath: string, value: any): void; + $add(keypath: string, value: any): void; + $delete(keypath: string): void; + $eval(expression: string): any; + $interpolate(templateString: string): string; + $log(keypath?: string): void; + + /** + * Events + */ + $dispatch(event: string, ...args: any[]): Vue; + $broadcast(event: string, ...args: any[]): Vue; + $emit(event: string, ...args: any[]): Vue; + $on(event: string, callback: Function): Vue; + $once(event: string, callback: Function): Vue; + $off(event?: string, callback?: Function): Vue; + + /** + * DOM + */ + $appendTo(element: any, callback?: Function): Vue;// element or selector + $prependTo(element: any, callback?: Function): Vue;// element or selector + $before(element: any, callback?: Function): Vue;// element or selector + $after(element: any, callback?: Function): Vue;// element or selector + $remove(callback?: Function): Vue; + + /** + * Lifecycle + */ + $mount(element?: any): Vue;// element or selector + $destroy(remove?: boolean): void; + $compile(element: HTMLElement): VueCallback;// returns a decompile function + $addChild(options?: Object, constructor?: Function): Vue; + + /** + * Global Api + * http://vuejs.org/api/global-api.html + */ + static config: VueConfig; + static extend(options: {}): Vue; + static directive(id: string, definition?: Object): void; + static directive(id: string, definition?: VueCallback): void; + static filter(id: string, definition?: VueCallback): void; + static component(id: string, definition: Vue): void; + static component(id: string, definition?: Object): void; + static transition(id: string, definition?: Object): void; + static partial(id: string, definition?: string): void; + static partial(id: string, definition?: HTMLElement): void; + static nextTick(callback: VueCallback): void; + static require(module: string): void; + static use(plugin: Object, ...args: any[]): Vue; + static use(plugin: VueCallback, ...args: any[]): Vue; + + /** + * exports members. + */ + _init(options: {}): void; + _cleanup(): void; + // static require(module:string) : void; + el: string; + data: {}; + ready: VueCallback; + beforeCompile: VueCallback; + compiled: VueCallback; + created: VueCallback; + attached: VueCallback; + detached: VueCallback; + beforeDestroy: VueCallback; + destroyed: VueCallback; + + directives: {}; + filters: {}; + partials: {}; + transitions: {}; + components: {}; + watch: {}; + events: {}; + methods: {}; + computed: {}; + + } + + class VueConfig { + prefix: string; + debug: boolean; + silent: boolean; + proto: boolean; + interpolate: boolean; + async: boolean; + delimiters: string[]; + } + + interface ValueCallback { + (newValue: {}, oldValue: {}): void; + } + + interface VueCallback { + (): void; + } +} +import Vue = vue.Vue; diff --git a/vue/vue.d.ts.tscparams b/vue/vue.d.ts.tscparams new file mode 100644 index 000000000..934bc29ef --- /dev/null +++ b/vue/vue.d.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny \ No newline at end of file From 017bd1372930d9ccaada2c3f81491ea1176eab81 Mon Sep 17 00:00:00 2001 From: odangosan Date: Sat, 27 Dec 2014 21:19:02 +0900 Subject: [PATCH 2/3] Update vue/vue.d.ts --- vue/vue.d.ts | 95 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 35 deletions(-) diff --git a/vue/vue.d.ts b/vue/vue.d.ts index 471bf1b63..601c3f152 100644 --- a/vue/vue.d.ts +++ b/vue/vue.d.ts @@ -3,7 +3,7 @@ // Definitions by: odangosan https://github.com/odangosan // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module vue { +declare module vuejs { export class Vue { /** * The Vue Constructor @@ -15,19 +15,62 @@ declare module vue { * Options * http://vuejs.org/api/options.html */ - // still... - + /** + * Data + * http://vuejs.org/api/options.html#Data + */ + data: {}; + methods: {}; + computed: {}; + paramAttributes:{}[]; + /** + * DOM + * http://vuejs.org/api/options.html#DOM + */ + el: {}; + template: string; + replace: boolean; + /** + * Lifecycle + * http://vuejs.org/api/options.html#Lifecycle + */ + created: VueCallback; + beforeCompile: VueCallback; + compiled: VueCallback; + ready: VueCallback; + attached: VueCallback; + detached: VueCallback; + beforeDestroy: VueCallback; + destroyed: VueCallback; + /** + * Assets + * http://vuejs.org/api/options.html#Assets + */ + directives: {}; + filters: {}; + components: {}; + partials: {}; + transitions: {}; + /** + * Others + * http://vuejs.org/api/options.html#Others + */ + inherit: boolean; + events: {}; + watch: {}; + mixins:{}[]; + name: string; /** * Instance Properties * http://vuejs.org/api/instance-properties.html */ $el: HTMLElement; - $data: Object; - $options: Object; + $data: {}; + $options: {}; $parent: Vue; $root: Vue; - $: Object; - $$: Object; + $: {}; + $$: {}; /** * Instance Methods @@ -70,7 +113,7 @@ declare module vue { $mount(element?: any): Vue;// element or selector $destroy(remove?: boolean): void; $compile(element: HTMLElement): VueCallback;// returns a decompile function - $addChild(options?: Object, constructor?: Function): Vue; + $addChild(options?: {}, constructor?: Function): Vue; /** * Global Api @@ -78,17 +121,17 @@ declare module vue { */ static config: VueConfig; static extend(options: {}): Vue; - static directive(id: string, definition?: Object): void; + static directive(id: string, definition?: {}): void; static directive(id: string, definition?: VueCallback): void; - static filter(id: string, definition?: VueCallback): void; + static filter(id: string, definition?: FilterCallback): void; static component(id: string, definition: Vue): void; - static component(id: string, definition?: Object): void; - static transition(id: string, definition?: Object): void; + static component(id: string, definition?: {}): void; + static transition(id: string, definition?: {}): void; static partial(id: string, definition?: string): void; static partial(id: string, definition?: HTMLElement): void; static nextTick(callback: VueCallback): void; static require(module: string): void; - static use(plugin: Object, ...args: any[]): Vue; + static use(plugin: {}, ...args: any[]): Vue; static use(plugin: VueCallback, ...args: any[]): Vue; /** @@ -97,27 +140,6 @@ declare module vue { _init(options: {}): void; _cleanup(): void; // static require(module:string) : void; - el: string; - data: {}; - ready: VueCallback; - beforeCompile: VueCallback; - compiled: VueCallback; - created: VueCallback; - attached: VueCallback; - detached: VueCallback; - beforeDestroy: VueCallback; - destroyed: VueCallback; - - directives: {}; - filters: {}; - partials: {}; - transitions: {}; - components: {}; - watch: {}; - events: {}; - methods: {}; - computed: {}; - } class VueConfig { @@ -137,5 +159,8 @@ declare module vue { interface VueCallback { (): void; } + interface FilterCallback { + (value:{},begin?:{},end?:{}): {}; + } } -import Vue = vue.Vue; +import Vue = vuejs.Vue; From 0788f3939b1ee858021e4f2c2cfc2cf00393e200 Mon Sep 17 00:00:00 2001 From: odangosan Date: Sat, 27 Dec 2014 21:24:43 +0900 Subject: [PATCH 3/3] Update vue/vue.d.ts Header format --- vue/vue.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vue/vue.d.ts b/vue/vue.d.ts index 601c3f152..31256aa4a 100644 --- a/vue/vue.d.ts +++ b/vue/vue.d.ts @@ -1,6 +1,6 @@ // Type definitions for vuejs 0.11.0 // Project: https://github.com/yyx990803/vue -// Definitions by: odangosan https://github.com/odangosan +// Definitions by: odangosan // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module vuejs {