baianat / hooper

🎠 A customizable accessible carousel slider optimized for Vue
https://baianat.github.io/hooper/
MIT License
720 stars 131 forks source link

Using with typescript in strict mode #165

Open RagazziMoscow opened 4 years ago

RagazziMoscow commented 4 years ago

I decided to migrate on Typescript with strict mode. Now i get an error during the compilation

To Reproduce Steps to reproduce the behavior:

  1. migrate to typescript
  2. set in your tsconfig.json strict: true option

Expected behavior There is no any errors

Actual behavior

TS7016: Could not find a declaration file for module 'hooper'. 'client/node_modules/hooper/dist/hooper.js' implicitly has an 'any' type.
  Try `npm install @types/hooper` if it exists or add a new declaration (.d.ts) file containing `declare module 'hooper';`

Does anyone have idea how to write the declaration for not getting this error ?

RagazziMoscow commented 4 years ago

I solved this problem by adding a new declaration for hooper to type declarations file in project:

declare module 'hooper' {
  import { FunctionalComponentOptions } from 'vue'
  export const Hooper: FunctionalComponentOptions
  export const Slide: FunctionalComponentOptions
  export const Navigation: FunctionalComponentOptions
}

It works. This issue can be closed.

abezulski commented 4 years ago

I think this issue needs to be open until official support is added or someone creates @types/hopper.

I added another entry to @RagazziMoscow module:

// hooper.d.ts
declare module 'hooper' {
  import { FunctionalComponentOptions } from 'vue'
  export const Hooper: FunctionalComponentOptions
  export const Slide: FunctionalComponentOptions
  export const Navigation: FunctionalComponentOptions
  export const Pagination: FunctionalComponentOptions // new entry for pagination
}