diff --git a/packages/generator-typescript/src/template-processor.ts b/packages/generator-typescript/src/template-processor.ts index 7dd8b9b2..050492e9 100644 --- a/packages/generator-typescript/src/template-processor.ts +++ b/packages/generator-typescript/src/template-processor.ts @@ -187,7 +187,10 @@ export class TemplateProcessor { } public getOutputPath(baseOutputPath: string, outputFilename: string): string { - const filePath = join(this.data?.importName || this.packageName, outputFilename) + // Create a directory for each package if package.json mode is enabled otherwise use the output directory directly + const filePath = this.config.package + ? join(this.data?.importName || this.packageName, outputFilename) + : outputFilename const outputPath = join(baseOutputPath, filePath) return outputPath } diff --git a/packages/generator-typescript/templates/gjs/dom.d.ts b/packages/generator-typescript/templates/gjs/dom.d.ts index 9d52c424..3ef10e90 100644 --- a/packages/generator-typescript/templates/gjs/dom.d.ts +++ b/packages/generator-typescript/templates/gjs/dom.d.ts @@ -1,6 +1,6 @@ <%_ const GLib = dep.find('GLib') -%> <%_ if(!package && GLib){ _%> -/// +/// <%_ } -%> /** diff --git a/packages/generator-typescript/templates/gjs/gjs.d.ts b/packages/generator-typescript/templates/gjs/gjs.d.ts index a5759d2d..0565b7cc 100644 --- a/packages/generator-typescript/templates/gjs/gjs.d.ts +++ b/packages/generator-typescript/templates/gjs/gjs.d.ts @@ -2,10 +2,10 @@ <%_ const GLib = await dep.get('GLib', '2.0') _%> <%_ if(!package){ -%> <%_ if(GObject){ -%> -/// +/// <% } -%> <%_ if(GLib){ -%> -/// +/// <% } -%> /// /// diff --git a/packages/generator-typescript/templates/gjs/system.d.ts b/packages/generator-typescript/templates/gjs/system.d.ts index 106be6e1..ea40f29d 100644 --- a/packages/generator-typescript/templates/gjs/system.d.ts +++ b/packages/generator-typescript/templates/gjs/system.d.ts @@ -1,6 +1,6 @@ <%_ const GObject = await dep.get('GObject', '2.0') _%> <%_ if(!package && GObject){ _%> -/// +/// <%_ } -%> <%- GObject ? GObject.importDef : '' %> diff --git a/tests/types-package/main.ts b/tests/types-package/main.ts index 5c255c05..2b16e39d 100644 --- a/tests/types-package/main.ts +++ b/tests/types-package/main.ts @@ -1,8 +1,8 @@ -import './@types/gjs/gjs.d.ts' -import './@types/gjs/dom.d.ts' -import './@types/gtk-2.0/gtk-2.0.d.ts' -import './@types/gtk-3.0/gtk-3.0.d.ts' -import './@types/gtk-4.0/gtk-4.0.d.ts' +import './@types/gjs.d.ts' +import './@types/dom.d.ts' +import './@types/gtk-2.0.d.ts' +import './@types/gtk-3.0.d.ts' +import './@types/gtk-4.0.d.ts' import Gettext from 'gettext' console.log(Gettext.textdomain)