dts-bundle-generator icon indicating copy to clipboard operation
dts-bundle-generator copied to clipboard

Output strips `type` keyword from type import

Open egilsster opened this issue 1 year ago • 3 comments

Bug report

The generator seems to remove the type import keyword from the source, this can be troublesome for projects that have verbatimModuleSyntax enabled:

error TS1484: 'MyType' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

I'd be happy to take a stab at this issue if there isn't anything I can use to get this working. Both the project that's compiling this has the type, and the project using the type has verbatimModuleSyntax enabled.

Input code

import type { MyType } from "@my-internal-lib/some-type";

export type MyExportedType = {
  property: MyType;
};

declare global {
  // type augmentation
}

Expected output

import type { MyType } from "@my-internal-lib/some-type";

export type MyExportedType = {
  property: MyType;
};

declare global {
  // type augmentation
}

Actual output

import { MyType } from "@my-internal-lib/some-type";

export type MyExportedType = {
  property: MyType;
};

declare global {
  // type augmentation
}

Additional context

I am using the JS API and here are my options:

generateDtsBundle([
  {
    filePath: String(entry),
    outFile: output,
    output: { inlineDeclareGlobals: true },
  },
])

egilsster avatar Apr 26 '24 06:04 egilsster

Duplicate of https://github.com/timocov/dts-bundle-generator/issues/290

timocov avatar Apr 26 '24 07:04 timocov

Hm, actually, if it just about imports, it could be different issue and probably can be solved separately. I'll check in couple of days what we can do.

timocov avatar Apr 26 '24 07:04 timocov

Took a stab at this @timocov https://github.com/timocov/dts-bundle-generator/pull/321

egilsster avatar May 05 '24 10:05 egilsster