From 8f3e62429cde2dcc8d748d9cfe1023b3744136f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9otix?= Date: Tue, 5 Dec 2017 13:54:29 +0100 Subject: [PATCH 1/3] Fix typo in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a8ac1a..f99cf42 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ this.$modal.show('dialog', { handler: () => { alert('Woot!') } }, { - titile: '', // Button title + title: '', // Button title default: true, // Will be triggered by default if 'Enter' pressed. handler: () => {} // Button click handler }, From af4afc926edd28545e0202e7fc222664e2363588 Mon Sep 17 00:00:00 2001 From: hmsk Date: Sun, 17 Dec 2017 17:21:27 -0800 Subject: [PATCH 2/3] Add type definitions --- package.json | 1 + types/index.d.ts | 21 +++++++++++++++++++++ types/test/index.ts | 16 ++++++++++++++++ types/test/tsconfig.json | 13 +++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 types/index.d.ts create mode 100644 types/test/index.ts create mode 100644 types/test/tsconfig.json diff --git a/package.json b/package.json index 11a198b..8ee4fc5 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "type": "git", "url": "https://github.com/euvl/vue-js-modal.git" }, + "types": "types/index.d.ts", "keywords": [ "vue", "vuejs", diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..a2a7d12 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,21 @@ +import Vue, { PluginObject } from "vue"; + +declare const VueJSModal: PluginObject; +export default VueJSModal; + +export declare interface VueJSModalOptions { + componentName?: string; + dialog?: boolean; +} + +declare interface VModal { + show(name: string, params?: object): void; + hide(name: string, params?: object): void; + toggle(name: string, params?: object): void; +} + +declare module "vue/types/vue" { + interface Vue { + $modal: VModal; + } +} diff --git a/types/test/index.ts b/types/test/index.ts new file mode 100644 index 0000000..7f29044 --- /dev/null +++ b/types/test/index.ts @@ -0,0 +1,16 @@ +import Vue from "vue"; +import VueJSModal, { VueJSModalOptions } from "../index"; + +Vue.use(VueJSModal); +Vue.use(VueJSModal, { + componentName: "another-modal-name", + dialog: false +}); + +const vm = new Vue({ + template: `` +}).$mount("#app"); + +vm.$modal.show("awesome-modal"); +vm.$modal.hide("awesome-modal", { customeEvent: "customEventParam" }); +vm.$modal.toggle("awesome-modal"); diff --git a/types/test/tsconfig.json b/types/test/tsconfig.json new file mode 100644 index 0000000..2acb656 --- /dev/null +++ b/types/test/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "es2015", + "moduleResolution": "node", + "strict": true, + "noEmit": true + }, + "include": [ + "*.ts", + "../index.d.ts" + ] +} From f6f330255c44bf24f47ce5e5cd73257e7e19d6f8 Mon Sep 17 00:00:00 2001 From: hmsk Date: Sun, 17 Dec 2017 17:23:07 -0800 Subject: [PATCH 3/3] Add npm script testing type --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8ee4fc5..d5d9cbe 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "build:server": "webpack --config ./build/webpack.server.config.js --progress --hide-modules", "lint": "eslint --ext .js,.vue src test/unit/specs", "unit": "./node_modules/karma/bin/karma start test/unit/karma.conf.js", - "build": "npm run lint && npm run unit && npm run build:client && npm run build:server" + "build": "npm run lint && npm run unit && npm run build:client && npm run build:server", + "test:types": "tsc -p types/test" }, "license": "MIT", "devDependencies": {