From a6f7ae13b9b039930a32d03bf81c1079c9d53593 Mon Sep 17 00:00:00 2001 From: Michael Tintiuc Date: Wed, 10 Oct 2018 18:14:29 +0300 Subject: [PATCH] Improve typescript typings and config --- .gitignore | 1 + build/rollup.config.js | 2 +- package.json | 3 +- src/api-utils.ts | 2 +- src/api.ts | 22 +++--- .../ion-vue-router-transitionless.vue | 2 +- src/components/ion-vue-router.vue | 9 +-- src/framework-delegate.ts | 2 +- src/{types/interfaces.d.ts => interfaces.ts} | 14 +++- src/mixins/catch-ionic-go-back.ts | 6 +- src/proxy-controller.ts | 2 +- src/proxy-delegate-controller.ts | 2 +- src/proxy-menu-controller.ts | 2 +- src/router.ts | 2 +- tsconfig.json | 10 ++- types/api-utils.d.ts | 4 + types/api.d.ts | 18 +++++ .../ion-vue-router-transitionless.vue.d.ts | 7 ++ types/components/ion-vue-router.vue.d.ts | 25 +++++++ types/framework-delegate.d.ts | 11 +++ types/index.d.ts | 4 + types/interfaces.d.ts | 75 +++++++++++++++++++ types/ionic.d.ts | 8 ++ types/mixins/catch-ionic-go-back.d.ts | 5 ++ types/proxy-controller.d.ts | 9 +++ types/proxy-delegate-controller.d.ts | 9 +++ types/proxy-menu-controller.d.ts | 16 ++++ types/router.d.ts | 19 +++++ types/types/interfaces.d.ts | 75 +++++++++++++++++++ 29 files changed, 332 insertions(+), 34 deletions(-) rename src/{types/interfaces.d.ts => interfaces.ts} (90%) create mode 100644 types/api-utils.d.ts create mode 100644 types/api.d.ts create mode 100644 types/components/ion-vue-router-transitionless.vue.d.ts create mode 100644 types/components/ion-vue-router.vue.d.ts create mode 100644 types/framework-delegate.d.ts create mode 100644 types/index.d.ts create mode 100644 types/interfaces.d.ts create mode 100644 types/ionic.d.ts create mode 100644 types/mixins/catch-ionic-go-back.d.ts create mode 100644 types/proxy-controller.d.ts create mode 100644 types/proxy-delegate-controller.d.ts create mode 100644 types/proxy-menu-controller.d.ts create mode 100644 types/router.d.ts create mode 100644 types/types/interfaces.d.ts diff --git a/.gitignore b/.gitignore index 629602e..da38761 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ node_modules/ coverage/ reports/ src/**/*.js +types/**/*.map # ignore log files *.log diff --git a/build/rollup.config.js b/build/rollup.config.js index 90250a8..937b55a 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -52,7 +52,7 @@ function baseConfig() { '@ionic/core/dist/ionic/svg', 'ionicons/dist/collection/icon/icon.css', ], - plugins: [vue(), typescript()], + plugins: [vue(), typescript({ useTsconfigDeclarationDir: true })], } } diff --git a/package.json b/package.json index 57cbcd3..5aaecfc 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,13 @@ "license": "MIT", "repository": "github:ModusCreateOrg/ionic-vue", "main": "dist/ionic-vue.common.js", - "typings": "dist/index.d.ts", + "typings": "types/index.d.ts", "module": "dist/ionic-vue.esm.js", "unpkg": "dist/ionic-vue.js", "jsdelivr": "dist/ionic-vue.js", "files": [ "src/", + "types/", "dist/*.js", "dist/*.ts" ], diff --git a/src/api-utils.ts b/src/api-utils.ts index 8ef6431..888f037 100644 --- a/src/api-utils.ts +++ b/src/api-utils.ts @@ -1,4 +1,4 @@ -import { HTMLStencilElement } from './types/interfaces'; +import { HTMLStencilElement } from './interfaces'; // A proxy method that initializes the controller and calls requested method export function proxyMethod(tag: string, method: string, ...opts: any[]): Promise { diff --git a/src/api.ts b/src/api.ts index 85c551e..8aa2594 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,5 +1,5 @@ import Vue, { PluginFunction } from 'vue'; -import { ApiCache, FrameworkDelegate } from './types/interfaces'; +import { ApiCache, FrameworkDelegate } from './interfaces'; import Delegate from './framework-delegate'; import ProxyController from './proxy-controller'; import ProxyMenuController from './proxy-menu-controller'; @@ -13,37 +13,37 @@ export default class Api { static install: PluginFunction; // Create or return a ActionSheetController instance - get actionSheetController(): typeof ProxyController { + get actionSheetController(): ProxyController { return getOrCreateController('ion-action-sheet-controller'); } // Create or return an AlertController instance - get alertController(): typeof ProxyController { + get alertController(): ProxyController { return getOrCreateController('ion-alert-controller'); } // Create or return a LoadingController instance - get loadingController(): typeof ProxyController { + get loadingController(): ProxyController { return getOrCreateController('ion-loading-controller'); } // Create or return a MenuController instance - get menuController(): typeof ProxyMenuController { + get menuController(): ProxyMenuController { return getOrCreateMenuController('ion-menu-controller'); } // Create or return a ModalController instance - get modalController(): typeof ProxyDelegateController { + get modalController(): ProxyDelegateController { return getOrCreateDelegatedController('ion-modal-controller'); } // Create or return a PopoverController instance - get popoverController(): typeof ProxyDelegateController { + get popoverController(): ProxyDelegateController { return getOrCreateDelegatedController('ion-popover-controller'); } // Create or return a ToastController instance - get toastController(): typeof ProxyController { + get toastController(): ProxyController { return getOrCreateController('ion-toast-controller'); } } @@ -82,7 +82,7 @@ Api.install = (Vue): void => { }; // Get existing Base controller instance or initialize a new one -function getOrCreateController(tag: string): typeof ProxyController { +function getOrCreateController(tag: string): ProxyController { if (!Api.cache[tag]) { Api.cache[tag] = new ProxyController(tag); } @@ -91,7 +91,7 @@ function getOrCreateController(tag: string): typeof ProxyController { } // Get existing Menu controller instance or initialize a new one -function getOrCreateMenuController(tag: string): typeof ProxyMenuController { +function getOrCreateMenuController(tag: string): ProxyMenuController { if (!Api.cache[tag]) { Api.cache[tag] = new ProxyMenuController(tag); } @@ -100,7 +100,7 @@ function getOrCreateMenuController(tag: string): typeof ProxyMenuController { } // Get existing Delegated controller instance or initialize a new one -function getOrCreateDelegatedController(tag: string): typeof ProxyDelegateController { +function getOrCreateDelegatedController(tag: string): ProxyDelegateController { if (!Api.cache[tag]) { Api.cache[tag] = new ProxyDelegateController(tag, _Delegate); } diff --git a/src/components/ion-vue-router-transitionless.vue b/src/components/ion-vue-router-transitionless.vue index e3854b0..1695a63 100644 --- a/src/components/ion-vue-router-transitionless.vue +++ b/src/components/ion-vue-router-transitionless.vue @@ -7,7 +7,7 @@