fuxingloh / vue-horizontal

An ultra simple pure vue horizontal layout for modern responsive web with zero dependencies. (SPA/SSG/SSR)
https://vue-horizontal.fuxing.dev
MIT License
227 stars 33 forks source link

vue-horizontal@next not yet support TS (Vue3) ? #126

Open renogies opened 10 months ago

renogies commented 10 months ago

vue-horizontal@next not yet support TS (Vue3) ?

renogies commented 10 months ago

src/main.ts:13:27 - error TS7016: Could not find a declaration file for module 'vue-horizontal'. 'C:/Github/project-vue3/node_modules/vue-horizontal/dist/vue-horizontal.umd.js' implicitly has an 'any' type. Try npm i --save-dev @types/vue-horizontal if it exists or add a new declaration (.d.ts) file containing declare module 'vue-horizontal';

13 import VueHorizontal from 'vue-horizontal';

linkurzweg commented 9 months ago

@renogies I managed to get around this by creating a declaration file like this. Make sure to have the file or the directory where you put it in your includes in the tsconfig.json.

vue-horizontal.d.ts:

declare module 'vue-horizontal' {
  import { DefineComponent } from 'vue'
  const VueHorizontal: DefineComponent<
    {
      button?: boolean
      buttonBetween?: boolean
      scroll?: boolean
      responsive?: boolean
      displacement?: number
      snap?: 'start' | 'center' | 'end' | 'none'
    },
    {
      prev: () => void
      next: () => void
      scrollToIndex: (index: number) => void
      scrollToLeft: (distance: number, scrollBehavior: 'smooth' | 'auto') => void
      refresh: () => void
    }
  >

  export default VueHorizontal
}