diff --git a/tsconfig.json b/tsconfig.json index 4a5ece01..8402fd67 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,13 @@ { "compilerOptions": { + "baseUrl": ".", "module": "commonjs", "removeComments": true, + "noImplicitThis": true, "noImplicitUseStrict": true }, - "files": ["packages/**/*"] + "include": [ + "types/**/*", + "packages/**/*" + ] } diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 00000000..7bc223dd --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,23 @@ +type Mixins = any[]; +type Relations = object; +type ExternalClasses = string[]; + +export interface Vue { + $emit(name: string, detail?: any): void; +} + +export type VantComponentOptions = { + data?: Data; + props?: Props; + field?: boolean; + mixins?: Mixins; + relations?: Relations; + classes?: ExternalClasses; + methods?: Methods & ThisType; + + // lifetimes + beforeCreate?: () => void; + created?: () => void; + mounted?: () => void; + destroyed?: () => void; +} diff --git a/types/weapp.d.ts b/types/weapp.d.ts new file mode 100644 index 00000000..92c675b8 --- /dev/null +++ b/types/weapp.d.ts @@ -0,0 +1,38 @@ +declare function Component(options: any): void; + +declare namespace Weapp { + interface Component { + getRelationNodes(selector: string): any[]; + setData(data: any, callback?: Function): void; + } + + interface Target { + id: string; + tagName: string; + dataset: any; + } + + interface Event { + type: string; + timeStamp: number; + target: Target; + currentTarget: Target; + } + + interface Touch { + identifier: number; + pageX: number; + pageY: number; + clientX: number; + clientY: number; + } + + interface TouchEvent extends Event { + touches: Array; + changedTouches: Array; + } + + interface CustomEvent extends Event { + detail: any; + } +}