index.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { Module } from '@nuxt/types/config';
  2. interface Component {
  3. pascalName: string;
  4. kebabName: string;
  5. import: string;
  6. asyncImport: string;
  7. export: string;
  8. filePath: string;
  9. shortPath: string;
  10. isAsync?: boolean;
  11. chunkName: string;
  12. /** @deprecated */
  13. global: boolean;
  14. level: number;
  15. prefetch: boolean;
  16. preload: boolean;
  17. }
  18. interface ScanDir {
  19. path: string;
  20. pattern?: string | string[];
  21. ignore?: string[];
  22. prefix?: string;
  23. isAsync?: boolean;
  24. /** @deprecated */
  25. global?: boolean | 'dev';
  26. pathPrefix?: boolean;
  27. level?: number;
  28. prefetch?: boolean;
  29. preload?: boolean;
  30. extendComponent?: (component: Component) => Promise<Component | void> | (Component | void);
  31. }
  32. interface ComponentsDir extends ScanDir {
  33. watch?: boolean;
  34. extensions?: string[];
  35. transpile?: 'auto' | boolean;
  36. }
  37. declare type componentsDirHook = (dirs: ComponentsDir[]) => void | Promise<void>;
  38. declare type componentsExtendHook = (components: (ComponentsDir | ScanDir)[]) => void | Promise<void>;
  39. interface Options {
  40. dirs: (string | ComponentsDir)[];
  41. loader: Boolean;
  42. }
  43. declare module '@nuxt/types/config/index' {
  44. interface NuxtOptions {
  45. components: boolean | Options | Options['dirs'];
  46. }
  47. }
  48. declare module '@nuxt/types/config/hooks' {
  49. interface NuxtOptionsHooks {
  50. 'components:dirs'?: componentsDirHook;
  51. 'components:extend'?: componentsExtendHook;
  52. components?: {
  53. dirs?: componentsDirHook;
  54. extend?: componentsExtendHook;
  55. };
  56. }
  57. }
  58. declare const componentsModule: Module<Options>;
  59. export { componentsModule as default };