diff --git a/docs/pages/en/1.getting-started/1.installation.md b/docs/pages/en/1.getting-started/1.installation.md index 172af68..7e6b6f2 100644 --- a/docs/pages/en/1.getting-started/1.installation.md +++ b/docs/pages/en/1.getting-started/1.installation.md @@ -43,18 +43,6 @@ You can now start using [``](/component/vue-testimonials) in y Remember that Vue Testimonials only supports Vue 3 (and Vite) projects! ::: -## TypeScript - -If you're using TypeScript, you may want to add additional types in your "types" array at `tsconfig.json`. - -```json [tsconfig.json] -{ - "compilerOptions": { - "types": ["vue-testimonials", "vite/client"] - } -} -``` - ## Upgrading :::alert{type="warning"} diff --git a/lib/index.d.ts b/lib/index.d.ts deleted file mode 100644 index 7f41f25..0000000 --- a/lib/index.d.ts +++ /dev/null @@ -1,120 +0,0 @@ -export interface Testimonial { - readonly title: string - readonly content: string - readonly image: string - readonly imageAlt?: string - readonly author: string -} - -declare module 'vue-testimonials' { - const _default: import('vue').DefineComponent< - { - interval: { - type: NumberConstructor - default: number - } - items: { - type: () => Testimonial[] - required: true - } - arrowColor: { - type: StringConstructor - default: string - } - arrowWidth: { - type: (NumberConstructor | StringConstructor)[] - default: string - } - arrowHeight: { - type: (NumberConstructor | StringConstructor)[] - default: string - } - ballActiveColorClass: { - type: StringConstructor - default: null - } - ballInactiveColorClass: { - type: StringConstructor - default: null - } - ballWidth: { - type: (NumberConstructor | StringConstructor)[] - default: string - } - ballHeight: { - type: (NumberConstructor | StringConstructor)[] - default: string - } - titleClasses: { - type: (StringConstructor | ObjectConstructor)[] - default: null - } - authorClasses: { - type: (StringConstructor | ObjectConstructor)[] - default: null - } - contentClasses: { - type: (StringConstructor | ObjectConstructor)[] - default: null - } - }, - { - clearCarousel: () => void - startCarousel: () => void - previousTestimonial: () => void - nextTestimonial: () => void - goToTestimonial: (index: number) => void - active: import('vue').Ref - arrowStyle: import('vue').ComputedRef<{ - color: string - width: string | number - height: string | number - }> - ballStyle: import('vue').ComputedRef<{ - width: string | number - height: string | number - }> - }, - unknown, - unknown, - unknown, - import('vue').ComponentOptionsMixin, - import('vue').ComponentOptionsMixin, - Record, - string, - import('vue').VNodeProps & - import('vue').AllowedComponentProps & - import('vue').ComponentCustomProps, - Readonly< - { - interval: number - items: Testimonial[] - arrowColor: string - arrowWidth: string | number - arrowHeight: string | number - ballActiveColorClass: string - ballInactiveColorClass: string - ballWidth: string | number - ballHeight: string | number - titleClasses: null - authorClasses: null - contentClasses: null - } & unknown - >, - { - interval: number - arrowColor: string - arrowWidth: string | number - arrowHeight: string | number - ballActiveColorClass: string - ballInactiveColorClass: string - ballWidth: string | number - ballHeight: string | number - titleClasses: null - authorClasses: null - contentClasses: null - } - > - - export default _default -} diff --git a/lib/index.ts b/lib/index.ts index e771dda..7cc578e 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -3,24 +3,24 @@ import VueTestimonials from './component/VueTestimonials.vue' let installed = false -function installFunction(Vue: App): void { +function install(Vue: App): void { if (installed) return installed = true Vue.component(VueTestimonials.name, VueTestimonials) } -let GlobalVue = null +let GlobalVue: any -const plugin = { install: installFunction } +const plugin = { install } -if (typeof window !== 'undefined') { - GlobalVue = (window as any).Vue -} else if (typeof global !== 'undefined') { - GlobalVue = (global as any).Vue +if (window && 'Vue' in window) { + GlobalVue = window['Vue'] +} else if (global && 'Vue' in global) { + GlobalVue = global['Vue'] } -if (GlobalVue) { +if (GlobalVue && typeof GlobalVue.use === 'function') { GlobalVue.use(plugin) } -export default { install: installFunction } +export default { install } diff --git a/lib/local-types/index.d.ts b/lib/local-types/index.d.ts deleted file mode 100644 index 0b37a61..0000000 --- a/lib/local-types/index.d.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { Testimonial } from './global' - -declare module 'vue-testimonials' { - const _default: import('vue').DefineComponent< - { - interval: { - type: NumberConstructor - default: number - } - items: { - type: () => Testimonial[] - required: true - } - arrowColor: { - type: StringConstructor - default: string - } - arrowWidth: { - type: (NumberConstructor | StringConstructor)[] - default: string - } - arrowHeight: { - type: (NumberConstructor | StringConstructor)[] - default: string - } - ballActiveColorClass: { - type: StringConstructor - default: null - } - ballInactiveColorClass: { - type: StringConstructor - default: null - } - ballWidth: { - type: (NumberConstructor | StringConstructor)[] - default: string - } - ballHeight: { - type: (NumberConstructor | StringConstructor)[] - default: string - } - titleClasses: { - type: (StringConstructor | ObjectConstructor)[] - default: null - } - authorClasses: { - type: (StringConstructor | ObjectConstructor)[] - default: null - } - contentClasses: { - type: (StringConstructor | ObjectConstructor)[] - default: null - } - }, - { - clearCarousel: () => void - startCarousel: () => void - previousTestimonial: () => void - nextTestimonial: () => void - goToTestimonial: (index: number) => void - active: import('vue').Ref - arrowStyle: import('vue').ComputedRef<{ - color: string - width: string | number - height: string | number - }> - ballStyle: import('vue').ComputedRef<{ - width: string | number - height: string | number - }> - }, - unknown, - unknown, - unknown, - import('vue').ComponentOptionsMixin, - import('vue').ComponentOptionsMixin, - Record, - string, - import('vue').VNodeProps & - import('vue').AllowedComponentProps & - import('vue').ComponentCustomProps, - Readonly< - { - interval: number - items: Testimonial[] - arrowColor: string - arrowWidth: string | number - arrowHeight: string | number - ballActiveColorClass: string - ballInactiveColorClass: string - ballWidth: string | number - ballHeight: string | number - titleClasses: null - authorClasses: null - contentClasses: null - } & unknown - >, - { - interval: number - arrowColor: string - arrowWidth: string | number - arrowHeight: string | number - ballActiveColorClass: string - ballInactiveColorClass: string - ballWidth: string | number - ballHeight: string | number - titleClasses: null - authorClasses: null - contentClasses: null - } - > - - export default _default -} diff --git a/package.json b/package.json index 5a931b4..8ad9de4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-testimonials", - "version": "0.1.7", + "version": "0.1.8", "description": "Vue Testimonials is a Vue 3 testimonials component made with Vite and TypeScript", "homepage": "https://github.com/guastallaigor/vue-testimonials#readme", "author": { @@ -37,7 +37,7 @@ ], "scripts": { "dev": "vite", - "build": "vue-tsc --noEmit && vite build && cpx 'lib/index.d.ts' 'dist'", + "build": "vue-tsc --noEmit && vite build", "serve": "vite preview", "lint:eslint": "eslint lib/**/*.{ts,vue}", "lint:prettier": "prettier -w -u lib/**/*.{ts,vue}", @@ -67,6 +67,7 @@ "eslint-plugin-vue": "^7.10.0", "husky": "^6.0.0", "prettier": "^2.3.0", + "rollup-plugin-typescript2": "^0.30.0", "typescript": "^4.1.3", "vite": "^2.3.5", "vite-svg-loader": "^2.0.2", diff --git a/tsconfig.json b/tsconfig.json index 4121156..f489dee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "sourceMap": true, "resolveJsonModule": true, "skipLibCheck": true, + "noImplicitAny": false, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "experimentalDecorators": true, diff --git a/vite.config.ts b/vite.config.ts index 241264e..6550952 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,7 @@ import type { UserConfig } from 'vite' import svgLoader from 'vite-svg-loader' import vue from '@vitejs/plugin-vue' +import typescript from 'rollup-plugin-typescript2' const path = require('path') const config: UserConfig = { @@ -12,7 +13,7 @@ const config: UserConfig = { }, ], }, - plugins: [vue(), svgLoader()], + plugins: [vue(), svgLoader(), typescript()], build: { lib: { entry: path.resolve(__dirname, 'lib/index.ts'), diff --git a/yarn.lock b/yarn.lock index 31fd3ab..383d4ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -265,6 +265,14 @@ estree-walker "^1.0.1" picomatch "^2.2.2" +"@rollup/pluginutils@^4.1.0": + version "4.1.0" + resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.1.0.tgz#0dcc61c780e39257554feb7f77207dceca13c838" + integrity sha512-TrBhfJkFxA+ER+ew2U2/fHbebhLT/l/2pRk0hfj9KusXUuRXd2v0R58AfaZK9VXDQ4TogOSEmICVrQAA3zFnHQ== + dependencies: + estree-walker "^2.0.1" + picomatch "^2.2.2" + "@trysound/sax@0.1.1": version "0.1.1" resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.1.1.tgz#3348564048e7a2d7398c935d466c0414ebb6a669" @@ -1654,6 +1662,15 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" +find-cache-dir@^3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.1.tgz#89b33fad4a4670daa94f855f7fbe31d6d84fe880" + integrity sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ== + dependencies: + commondir "^1.0.1" + make-dir "^3.0.2" + pkg-dir "^4.1.0" + find-index@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" @@ -1672,7 +1689,7 @@ find-root@1.1.0: resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4" integrity sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng== -find-up@^4.1.0: +find-up@^4.0.0, find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== @@ -2507,6 +2524,13 @@ magic-string@^0.25.7: dependencies: sourcemap-codec "^1.4.4" +make-dir@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" + integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== + dependencies: + semver "^6.0.0" + map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -2908,6 +2932,13 @@ picomatch@^2.2.1, picomatch@^2.2.2, picomatch@^2.2.3: resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== +pkg-dir@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" @@ -3176,7 +3207,7 @@ resolve-url@^0.2.1: resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.1.7, resolve@^1.10.0, resolve@^1.17.0, resolve@^1.19.0, resolve@^1.20.0: +resolve@1.20.0, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.17.0, resolve@^1.19.0, resolve@^1.20.0: version "1.20.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== @@ -3216,6 +3247,17 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" +rollup-plugin-typescript2@^0.30.0: + version "0.30.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.30.0.tgz#1cc99ac2309bf4b9d0a3ebdbc2002aecd56083d3" + integrity sha512-NUFszIQyhgDdhRS9ya/VEmsnpTe+GERDMmFo0Y+kf8ds51Xy57nPNGglJY+W6x1vcouA7Au7nsTgsLFj2I0PxQ== + dependencies: + "@rollup/pluginutils" "^4.1.0" + find-cache-dir "^3.3.1" + fs-extra "8.1.0" + resolve "1.20.0" + tslib "2.1.0" + rollup@^2.38.5: version "2.50.6" resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.50.6.tgz#24e2211caf9031081656e98a5e5e94d3b5e786e2" @@ -3276,6 +3318,11 @@ semver@7.3.5, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: dependencies: lru-cache "^6.0.0" +semver@^6.0.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + set-value@^2.0.0, set-value@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" @@ -3657,6 +3704,11 @@ trim-off-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= +tslib@2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a" + integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A== + tslib@^1.8.1, tslib@^1.9.0: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"