Skip to content

Commit d24b068

Browse files
committed
Merge pull request vuejs#11 from kaorun343/add-typescript-definition-file
add typescript definition file
2 parents 2bd8c66 + 10f5d06 commit d24b068

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed

index.d.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
export interface PropOption {
2+
type?: { (...args: any[]): any; };
3+
required?: boolean;
4+
default?: any;
5+
twoWay?: boolean;
6+
validator?: (value: any) => boolean;
7+
coerce?: (value: any) => any;
8+
}
9+
10+
export interface WatchOption {
11+
handler(val: any, oldVal: any): void;
12+
deep?: boolean;
13+
immidiate?: boolean;
14+
}
15+
16+
export interface DirectiveOption {
17+
bind?(): any;
18+
update?(newVal?: any, oldVal?: any): any;
19+
unbind?(): any;
20+
params?: string[];
21+
deep?: boolean;
22+
twoWay?: boolean;
23+
acceptStatement?: boolean;
24+
priority?: boolean;
25+
[key: string]: any;
26+
}
27+
28+
export interface FilterOption {
29+
read?: Function;
30+
write?: Function;
31+
}
32+
33+
export interface TransitionOption {
34+
css?: boolean;
35+
beforeEnter?(el: HTMLElement): void;
36+
enter?(el: HTMLElement, done?: () => void): void;
37+
afterEnter?(el: HTMLElement): void;
38+
enterCancelled?(el: HTMLElement): void;
39+
beforeLeave?(el: HTMLElement): void;
40+
leave?(el: HTMLElement, done?: () => void): void;
41+
afterLeave?(el: HTMLElement): void;
42+
leaveCancelled?(el: HTMLElement): void;
43+
stagger?(index: number): number;
44+
}
45+
46+
export interface ComponentOption {
47+
props?: string[] | { [key: string]: (PropOption | { new (...args: any[]): any; }) };
48+
watch?: { [key: string]: ((val: any, oldVal: any) => void) | string | WatchOption };
49+
template?: string;
50+
directives?: { [key: string]: (DirectiveOption | Function) };
51+
elementDirectives?: { [key: string]: (DirectiveOption | Function) };
52+
filters?: { [key: string]: (Function | FilterOption) };
53+
components?: { [key: string]: any };
54+
transitions?: { [key: string]: TransitionOption };
55+
partials?: { [key: string]: string };
56+
parent?: any;
57+
events?: { [key: string]: ((...args: any[]) => (boolean | void)) | string };
58+
mixins?: ComponentOption[];
59+
name?: string;
60+
[key: string]: any;
61+
}
62+
63+
declare var decorator: (options: ComponentOption) => ClassDecorator;
64+
65+
export default decorator;

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Object.defineProperty(exports, '__esModule', {
2+
value: true
3+
})
4+
15
var Vue = require('vue')
26

37
var internalHooks = [
@@ -60,4 +64,4 @@ function decorator (options) {
6064
}
6165
}
6266

63-
module.exports = decorator
67+
exports.default = decorator

tsconfig.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"isolatedModules": false,
7+
"jsx": "react",
8+
"experimentalDecorators": true,
9+
"emitDecoratorMetadata": true,
10+
"declaration": true,
11+
"noImplicitAny": true,
12+
"removeComments": true,
13+
"noLib": false,
14+
"preserveConstEnums": true,
15+
"suppressImplicitAnyIndexErrors": true
16+
},
17+
"exclude": [
18+
"node_modules"
19+
],
20+
"compileOnSave": false,
21+
"buildOnSave": false,
22+
"atom": {
23+
"rewriteTsconfig": false
24+
}
25+
}

0 commit comments

Comments
 (0)