Skip to content

Commit f9eb42e

Browse files
committed
added TypeScript typings
resolves foxbenjaminfox#25
1 parent 0e6fa13 commit f9eb42e

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "3.5.0",
44
"description": "Async computed properties for Vue",
55
"main": "dist/vue-async-computed.js",
6+
"types": "types/index.d.ts",
67
"files": [
78
"bin/",
89
"dist/"

Diff for: types/index.d.ts

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Vue, { PluginFunction } from "vue";
2+
3+
export interface IAsyncComputedOptions {
4+
errorHandler?: (error: string | Error) => void;
5+
useRawError?: boolean;
6+
}
7+
8+
export default class AsyncComputed {
9+
constructor(options?: IAsyncComputedOptions)
10+
static install: PluginFunction<never>;
11+
static version: string;
12+
}
13+
14+
type AsyncComputedGetter<T> = () => Promise<T>;
15+
interface IAsyncComputedValue<T> {
16+
default?: T | (() => T);
17+
get: AsyncComputedGetter<T>;
18+
watch?: () => void;
19+
shouldUpdate?: () => boolean;
20+
lazy?: boolean;
21+
}
22+
23+
// tslint:disable-next-line:interface-name
24+
interface AsyncComputedObject {
25+
[K: string]: AsyncComputedGetter<any> | IAsyncComputedValue<any>;
26+
}
27+
28+
declare module "vue/types/options" {
29+
// tslint:disable-next-line:interface-name
30+
interface ComponentOptions<V extends Vue> {
31+
asyncComputed?: AsyncComputedObject;
32+
}
33+
}
34+
35+
interface IASyncComputedState {
36+
state: "updating" | "success" | "error";
37+
updating: boolean;
38+
success: boolean;
39+
error: boolean;
40+
exception: Error | null;
41+
update: () => void;
42+
}
43+
44+
declare module "vue/types/vue" {
45+
interface Vue {
46+
$asyncComputed: {[K: string]: IASyncComputedState };
47+
}
48+
}

0 commit comments

Comments
 (0)