0

I’m encountering some issues with creating and exporting TypeScript types in my library. Specifically, I have several challenges:

#1. Build Errors with Vite

When I try to build the library using vite build, I encounter several errors. For example:

lib/main.ts:1:26 - error TS6307: File 'Path/To/file/src/components/Buttons/index.ts' is not listed within the file list of project 'Path/To/file/tsconfig.app.json'. Projects must list all files or use an 'include' pattern.
  The file is in the program because:
    Imported via '@/components/Buttons/index' from file 'Path/To/file/lib/main.ts'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Drawers/SvSidebar.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Inputs/SvListbox.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Dialog/SvDialog.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Disclosure/SvDisclosure.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Tabs/SvTab.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Tabs/SvTabs.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Sandbox/SvCode.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Draggables/SvFilePreview.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Draggables/SvDragUpload.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Stats/SvIndicator.vue'
    Imported via '@/components/Buttons' from file 'Path/To/file/src/components/Sliders/SvCarousel.vue'

1 export { SvButton } from '@/components/Buttons/index'

I resolved this issue by modifying tsconfig.app.json and setting composite to false. However, I’m not entirely sure if this is an appropriate or recommended solution. tsconfig.app.json

#2. TypeScript Not Recognized in Components

I’m also uncertain about how to handle this issue as I’m still new to TypeScript documentation. The problem is that when I use the components in my testing file, I can see the IDE’s hints: Library project

But when I compile the library and try to serve it on a project, there is no hint at all: Served project

Honestly, I don't know how to solve this, probably the problem is that I have a weird folder structure. this is an image of my folder structure:

folder_structure

Later on if you need so, I can prepare a github repo to show it more in detail.


I've tried to create an auto-generated .d.ts file that exports the components. The library doesn't recognize the file, and actually I don't know if this is appropiate too.

0

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.