Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output strips type keyword from type import #320

Open
egilsster opened this issue Apr 26, 2024 · 3 comments
Open

Output strips type keyword from type import #320

egilsster opened this issue Apr 26, 2024 · 3 comments

Comments

@egilsster
Copy link

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 },
  },
])
@timocov
Copy link
Owner

timocov commented Apr 26, 2024

Duplicate of #290

@timocov timocov marked this as a duplicate of #290 Apr 26, 2024
@timocov timocov closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
@timocov
Copy link
Owner

timocov commented Apr 26, 2024

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.

@egilsster
Copy link
Author

Took a stab at this @timocov #321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants