lycHub / ysx-library

ysx component libraries
MIT License
19 stars 9 forks source link

Type problems on type check #15

Open carlos22 opened 2 weeks ago

carlos22 commented 2 weeks ago

My type checker says:

There are types at 'node_modules/@ysx-libs/vue-virtual-tree/dist/typings/tree/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@ysx-libs/vue-virtual-tree' library may need to update its package.json or typings.

I think you need to also export the type files? But not sure why. I use regular npm 10.2.4.

carlos22 commented 2 weeks ago

This seems to solve it, move the types inside of the export: https://stackoverflow.com/a/77566206

carlos22 commented 2 weeks ago
  "types": "./dist/typings/tree/index.d.ts",
  "exports": {
    ".": {
      "import": {
        "types": "./dist/typings/tree/index.d.ts",
        "default": "./dist/vue-virtual-tree.es.js"
      },
      "require": {
        "types": "./dist/typings/tree/index.d.ts",
        "default": "./dist/vue-virtual-tree.umd.js"
      }
    },
    "./style.css": "./dist/style.css"
  },
carlos22 commented 2 weeks ago

But this is still a bit odd when importing VirTree, maybe you should export VirTree as default? My IDE has problems to distinguish between the type and the real impl.

lycHub commented 2 weeks ago

Update to v0.0.8 Try it out

carlos22 commented 2 weeks ago

this works for the types very good, but now I have:

MyTree.vue:2:10 - error TS1484: 'VirTree' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

not sure how to fix that. It does think VirTree is a type and not a component.

lycHub commented 2 weeks ago

image

Can reference this demo

carlos22 commented 2 weeks ago

Yes I know, but we use verbatimModuleSyntax so only type imports will be dropped in the output, and that seems to be not correctly determined.

grafik grafik

lycHub commented 2 weeks ago

update to v0.0.9 than can be import like:

image

carlos22 commented 2 weeks ago

Very cool, that seems to work good! Thank you very much.