Hey, a couple of words re: enum merging.
When you use enums, you’re basically converting said value to an enumerable value, by default, a number that starts from 0.
So, this:
enum WeatherType {
CLOUDY,
SUNNY,
RAIN
}has the same value as this:
enum WeatherType {
CLOUDY = 0,
SUNNY = 1,
RAIN = 2
}You can also define enums with custom values as well.
However, what they meant by “enum merging” might be combining two different enums together, e.g.
type MyMergedEnum = AnEnum & AnotherEnum;Since nothing outside TypeScript understands the type information that these enum values together, the second enum won’t begin at the number where the first enum left off. I might be wrong either, but as a TypeScripter I’ve never used this feature as well. :)
While we’re at it, another feature that TypeScript doesn’t support are “const enums”, which are enums that are converted to its final value at compile time. This also requires TS type information, so we can’t transpile this with Babel as well.
And that’s all you need to know about enums and enum merging!
