0

So my project structure looks like this:

src/
  button/
    j-button.ts
    j-button.test.ts

And I build my project in vite which outputs

dist/
  j-button.js

then I have

"types": "index.d.ts"

in my component lib package.json

But my index.d.ts file that tsc --outFile index.d.ts outputs looks like this:

declare module "button/j-button" {
 ...
}

and I think thats breaking my types because the import in the consuming app looks like this:

import JButton from '@jump/components/dist/j-button'

and so I assume typescript is looking for a declare module "dist/j-button" instead of button/j-button right?

How do I configure typescript to call these modules the right thing?

atomkirk
  • 3,701
  • 27
  • 30
  • Shouldn't vite be generating declaration files? – kelsny Mar 01 '23 at 21:07
  • kinda seems like vite doesn't do it for library mode. I'm just using the build command that came with the template `"build": "tsc --outFile index.d.ts && vite build"`, but this suggests another way of doing it? https://stackoverflow.com/questions/71982849/how-do-i-add-types-to-a-vite-library-build – atomkirk Mar 01 '23 at 21:10

0 Answers0