From 31595da88c50811d800365da28b6411f36e0ed49 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Fri, 15 Mar 2024 15:36:13 +0100 Subject: [PATCH] fix: use build aliases and set declaration as ts file --- src/module.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/module.ts b/src/module.ts index 35c2195..009e100 100644 --- a/src/module.ts +++ b/src/module.ts @@ -119,7 +119,7 @@ export default defineNuxtModule({ }) addImportsSources({ - from: resolve(nuxt.options.buildDir, `${moduleName}.d.ts`), + from: resolve(nuxt.options.buildDir, `${moduleName}.ts`), imports: schemas.flatMap(({ fetchName }) => Object.values(fetchName)), }) @@ -152,12 +152,12 @@ export default defineNuxtModule({ }]) addTemplate({ - filename: `${moduleName}.d.ts`, + filename: `${moduleName}.ts`, getContents() { return ` -import { createUseOpenFetch } from './imports.d.ts' +import { createUseOpenFetch } from '#imports' ${schemas.map(({ name }) => ` -import type { paths as ${pascalCase(name)}Paths } from './types/${moduleName}/schemas/${kebabCase(name)}.d.ts' +import type { paths as ${pascalCase(name)}Paths } from '#build/types/${moduleName}/schemas/${kebabCase(name)}.d.ts' `.trimStart()).join('').trimEnd()} ${schemas.length ? `export type OpenFetchClientName = ${schemas.map(({ name }) => `'${name}'`).join(' | ')}` : ''} @@ -186,9 +186,9 @@ export const ${fetchName.lazyComposable} = createUseOpenFetch<${pascalCase(name) addTypeTemplate({ filename: `types/${moduleName}/nuxt.d.ts`, getContents: () => ` -import type { OpenFetchClient } from '../../imports.d.ts' +import type { OpenFetchClient } from '#imports' ${schemas.map(({ name }) => ` -import type { paths as ${pascalCase(name)}Paths } from './schemas/${kebabCase(name)}.d.ts' +import type { paths as ${pascalCase(name)}Paths } from '#build/types/${moduleName}/schemas/${kebabCase(name)}.d.ts' `.trimStart()).join('').trimEnd()} declare module '#app' { @@ -211,9 +211,9 @@ export {} addTemplate({ filename: `types/${moduleName}/nitro.d.ts`, getContents: () => ` -import type { OpenFetchClient } from '../../imports.d.ts' +import type { OpenFetchClient } from '#imports' ${schemas.map(({ name }) => ` -import type { paths as ${pascalCase(name)}Paths } from './schemas/${kebabCase(name)}.d.ts' +import type { paths as ${pascalCase(name)}Paths } from '#build/types/${moduleName}/schemas/${kebabCase(name)}.d.ts' `.trimStart()).join('').trimEnd()} declare module 'nitropack' {