Skip to content

Import not consistent with export when transpiling enums as union types #232

@Pragmateek

Description

@Pragmateek

Hello,

I have a simple enum:

[ExportTsEnum(AsUnionType = true)]
public enum Digit
{
    Zero,
    One,
    Two,
    Three
}

It correctly generates:

export type Digit = "Zero" |
    "One" |
    "Two" |
    "Three"

The enum is used by a class:

public class Number
{
    public Digit FirstDigit { get; set; }
}

Which is transpiled in number.ts with this import:

import { Digit } from "./digit";

Which generates error (TS) 'Digit' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled..
I can manually fix the import :

import { type Digit } from "./digit";

But of course it is overriden on each build.

What is the correct way to fix this inconsistency?

I see that I can workaround the issue by tweaking the TSC configuration: //"verbatimModuleSyntax": true, but I guess it is a sensible default I should keep if possible.

Thanks and best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions