0

I know that an enum in Typescript compiles down to an object for runtime. I wanted to merge two enums enum EnumOne { ... }; enum EnumTwo { ... } with Object.assign(). That works.

In doing so, Typescript tells me, that the product of that is typeof EnumOne & typeof EnumTwo. So far, so good.

Now, Typescript also lets me know that “EnumOne is not assignable to typeof EnumOne”, which sounds reasonable, but it makes me wonder, what actually does typeof EnumOne mean? What is that? I cannot get the Typescript compiler to give me any meaningful information on it.

ghost23
  • 2,150
  • 1
  • 20
  • 35
  • `EnumOne` is a type which can hold a specific enum. `typeof EnumOne` is a type which can hold the type of `EnumOne`, or one of its subtypes. – MTCoster Feb 14 '19 at 15:38
  • "... can hold the type of EnumOne, ..." hold the type means: as a union type? Because as a union type would mean EnumOne would be part of "typeof EnumOne", which it is not, as the message suggests. I am still confused :) – ghost23 Feb 14 '19 at 15:42
  • 1
    Have you got an [mcve]? –  Feb 14 '19 at 16:00
  • @jcalz, thanks, that helps. – ghost23 Feb 14 '19 at 16:11

0 Answers0