add types definition

This commit is contained in:
nomnes 2019-08-06 20:30:34 +07:00
parent 8988085bef
commit 847e567cc2
2 changed files with 32 additions and 0 deletions

31
index.d.ts vendored Normal file
View file

@ -0,0 +1,31 @@
import SocketIOClient from "socket.io-client";
import {
DefaultComputed,
DefaultData,
DefaultMethods,
DefaultProps,
PropsDefinition,
} from "vue/types/options";
import { Vue } from "vue/types/vue";
interface socketHandler<T> {
(this: T, ...args: any[]): SocketIOClient.Socket
}
declare module 'vue/types/vue' {
interface Vue {
$socket: SocketIOClient.Socket
}
}
declare module 'vue/types/options' {
interface ComponentOptions<
V extends Vue,
Data=DefaultData<V>,
Methods=DefaultMethods<V>,
Computed=DefaultComputed,
PropsDef=PropsDefinition<DefaultProps>,
Props=DefaultProps> {
sockets: {[key: string]: socketHandler<V>}
}
}

View file

@ -38,6 +38,7 @@
"@babel/preset-env": "^7.1.0",
"babel-loader": "^8.0.4",
"cross-env": "^5.2.0",
"vue": "^2.6.10",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2"
}