yuanchuan / sveltekit-autoimport

Automatically detect and import components/modules for SvelteKit projects
https://npm.im/sveltekit-autoimport
MIT License
231 stars 10 forks source link

add d.ts file generate #21

Closed Mohamed-Kaizen closed 2 years ago

Mohamed-Kaizen commented 2 years ago

related to #3, although it doesn't fix the svelte-check(missing-declaration) issue, but it does fix the issue with the typescript

labcorg commented 2 years ago

I tried to use your nice feature addition, got an error which could be precised when dts field is not specified in the autoImport config and this does not take into account the module field for node_modules imports like the following :

autoImport({
  dts: "./src/components-auto-imports.d.ts",
  module: {
    'flowbite-svelte': [
      'Button',
      'GradientMonochromeButton'
    ]
  }
})

I guess the desired dts output (for this specific case) looks like this

// Generated by 'sveltekit-autoimport'
export {}
declare global {
  export const { Button, GradientMonochromeButton } = import('flowbite-svelte')
}
Mohamed-Kaizen commented 2 years ago

Yeah, i didn't consider module base components 😅. Let me close this PR, i will try to figure out how to do that. Thanks for the feed back