[Bug]: Vue2 Legacy missing typescript definitions
See original GitHub issueWould you like to work on a fix?
- Check this if you would like to implement a PR, we are more than happy to help you go through the process.
Current and expected behavior
Following the example on https://vue-chartjs.org/guide/#creating-your-first-chart I run into an issue with typescript:
Could not find a declaration file for module 'vue-chartjs/legacy'. '.../node_modules/vue-chartjs/legacy/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/vue-chartjs` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-chartjs/legacy';`Vetur(7016)
Unfortunatley there are no types for this project available at https://github.com/DefinitelyTyped/DefinitelyTyped
I could solve this issue by using vue-chartjs@3.5.1
.
Reproduction
https://vue-chartjs.org/guide/#creating-your-first-chart
chart.js version
3.7.1
vue-chartjs version
4.0.6
Possible solution
Add type definitions for the legacy package of vue-chartjs
Issue Analytics
- State:
- Created a year ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Typescript - adding typing to custom Vue2 plugin: "File is not a ...
I get this second error, which I believe just means that the declaration file is not being parsed (because changes in it do...
Read more >TypeScript Support - Vue I18n - Intlify
If you compile typescript in this state, you will get the following error to check that no ja-JP resource is defined in the...
Read more >@types/vue | Yarn - Package Manager
This is a stub types definition for vuejs (https://github.com/vuejs/vue). vuejs provides its own type definitions, so you don't need @types/vue installed!
Read more >ts-loader - npm
TypeScript loader for webpack. Latest version: 9.4.2, last published: 25 days ago. Start using ts-loader in your project by running `npm i ...
Read more >CLI Service - Vue CLI
[entry] in the CLI command is defined as the entry file (default: src/main.js or src/main.ts in TypeScript project), not an additional entry ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@thabarbados thanks for the quick fix. Types are there now and at least the bar chart works flawlessly (as far as I can see). Unfortunately chart types other than the bar chart cannot be used as Vue components.
Minimal example:
Funny thing is that while the error is reported, you can see the rendered chart in the background.
index.d.ts
@glennpierce
Sorry, I don’t have any idea how you can try my repository easily.
But I can tell you my way
pnpm build
and please check emitted index.d.tsyour/project/node_modules/vue-chartjs/index.d.ts
andyoooz/vue-chartjs/index.dts
Even if
yoooz/vue-chartjs
add yourpackage.json
, installing onlyyoooz/vue-chartjs/package.json only
. I think easily install my commit if my pull request merged.