0

I want to use vue-simple-spinner in my project, but when I import it I get the following error:

Could not find a declaration file for module 'vue-simple-spinner'. 
'c:/Users/Korisnik/Desktop/projects/typescript-chord-app/node_modules/vue- 
simple-spinner/dist/vue-simple-spinner.js' implicitly has an 'any' type.
Try `npm install @types/vue-simple-spinner` if it exists or add a new 
declaration (.d.ts) file containing `declare module 'vue-simple-spinner';`

I created shims-spinner.d.ts file:

declare module 'vue-simple-spinner' {
  import Spinner from 'vue-simple-spinner';
  export default Spinner;
}

but then I get Circular definition of import alias 'Spinner'.

How can I fix this?

2
  • 1
    Don't declare your module with the same name as the module you're importing from? Commented Nov 26, 2018 at 14:34
  • @RoyJ That helps, but I still get the first error, only now in shims-spinner.d.ts. Commented Nov 26, 2018 at 14:49

1 Answer 1

2

In order to import and render the Spinner module, you should be able to do so by placing:

declare module 'vue-simple-spinner' {
  const spinner: any;
  export default spinner;
 }

In your shims.d.ts.

If you want to use a more complex type (which I don't think has any use in this case, since you're only importing the Spinner to render it in html) you can replace the any typing with anything that makes sense.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.