ecomfe / vue-echarts

Vue.js component for Apache ECharts™.
https://vue-echarts.dev
MIT License
9.43k stars 1.48k forks source link

Types broken with ECharts 5.5 + Vue 3 + `moduleResolution: bundler` #766

Closed kingyue737 closed 4 months ago

kingyue737 commented 4 months ago

Confirmation

How are you introducing Vue-ECharts into your project?

ES Module imports

Versions

+-- @vitejs/plugin-vue@5.0.4
| `-- vue@3.4.19 deduped
+-- echarts@5.5.0
+-- vue-echarts@6.6.9
| +-- echarts@5.5.0 deduped
| +-- vue-demi@0.13.11
| | `-- vue@3.4.19 deduped
| `-- vue@3.4.19 deduped
`-- vue@3.4.19
  `-- @vue/server-renderer@3.4.19
    `-- vue@3.4.19 deduped

Details

Expected: image

In fact: image

I found that ECharts v5.5.0 does not add files of ./types/dist/ to exports in package.json like following:

{
  "exports":{
      "./types/dist/shared":"./types/dist/shared.js",
  }
}

End users need to import types from echarts/types/dist/shared.js instead of echarts/types/dist/shared when moduleResolution is bundler in tsconfig (recommended by vite, default in create-vue and will become default in nuxt). Although it doesn't matter if users only use ECharts itself, users of Vue ECharts will meet broken types as Vue ECharts imports echarts/types/dist/shared instead of echarts/types/dist/shared.js in its output: image

Or should I request it in ECharts Repo?

Reproduction

https://stackblitz.com/edit/vitejs-vite-svx9rd

In the repro, npm run typecheck should have printed error because I've set :update-options="{ bug: 'bug' }". But the type-check passed because update-options is any here.

Justineo commented 4 months ago

The generated .d.ts of vue-echarts shouldn't produce echarts/types/dist/shared in the first place. And after some investigation we found that there are some type issues in ECharts itself. After discussing this with the maintainers of ECharts we agree that this should be fixed on their side. We don't currently have a schedule for this yet, unfortunately.