What does it mean: Enum declarations can only merge with namespace or other enum declarations

Viewed 1979

I got this error in my Types.ts file

./sharedDirectory/Types.ts:880:13 Type error: Enum declarations can only merge with namespace or other enum declarations.

878 | }*/ 879 |

880 | export enum InvoiceProvider { | ^ 881 | No = "-", 882 | Billingo = "Billingo", 883 | Szamlazzhu = "szamlazz.hu", error Command failed with exit code 1.

I have following relating decaltarions:

export enum InvoiceProvider { // <---- ERROR here
  No = "-",
  Billingo = "Billingo",
  Szamlazzhu = "szamlazz.hu",
}

export type SelectItemKeys =
  | InvoiceProvider
  | PaymentProviderName
  | SzamlazzhuVatKeys
  | BillingoVatKeys
  | PricingAndInvoicingType
  | InvoiceFulfillmentDate
  | InvoiceItemQuantityType;

export let selectItemList: {
  [selectItemDataOptionId: string]: SelectItemData<SelectItemKeys>;
} = {
  selectedInvoiceProvider: new SelectItemData<InvoiceProvider>(
    {
      InvoiceProvider.No: {"hu": "-", "en": "-"},
      InvoiceProvider.Billingo: {"hu": "Billingo", "en": "Billingo"},
      InvoiceProvider.Szamlazzhu: {"hu": "Szamlazz.hu", "en": "Szamlazz.hu"},
    },
    InvoiceProvider.No
  ),
};

I do not see what is wrong. Do you have any idea?

1 Answers

You had syntax error.

You need to wrap enum property into square brackets.

[InvoiceProvider.No]

Example:

export enum InvoiceProvider { 
  No = "-",
  Billingo = "Billingo",
  Szamlazzhu = "szamlazz.hu",
}
class SelectItemData{}

export type SelectItemKeys =
  | InvoiceProvider
  | PaymentProviderName
  | SzamlazzhuVatKeys
  | BillingoVatKeys
  | PricingAndInvoicingType
  | InvoiceFulfillmentDate
  | InvoiceItemQuantityType;

export let selectItemList: {
  [selectItemDataOptionId: string]: SelectItemData<SelectItemKeys>;
} = {
  selectedInvoiceProvider: new SelectItemData<InvoiceProvider>(
    {
      [InvoiceProvider.No]: {"hu": "-", "en": "-"}, // <--- [InvoiceProvider.No] in square brackets
      [InvoiceProvider.Billingo]: {"hu": "Billingo", "en": "Billingo"},
      [InvoiceProvider.Szamlazzhu]: {"hu": "Szamlazz.hu", "en": "Szamlazz.hu"},
    },
    InvoiceProvider.No
  )
}

If you are using computed property names, they should be wrapped into square brackets

Related