|
|
|
|
|
by Izkata
1613 days ago
|
|
The modern Javascript version of that would be the same as the compiled Typescript version, the const version doesn't do the same things. The IIFE is creating an object only if it doesn't already exist, and adds "A" and "B" to it. "var" doesn't error on a redeclaration, so if MyType already existed you'll get a mashup of the two versions of it. Even if the const was switched to var in the second one, that would still be a straight replacement of the values instead of merging them. I haven't used Typescript, but I imagine this style was used so enums could gain new values later in the code without having to worry about execution order. |
|
I think I was still accidentally correct in saying that's what we'd write because who the hell actually WANTS the default behavior? :p