You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are certain situations where we do get errors for redefining classes. FunctionTypeBuilder throws an error when the constructor signatures are different.
If the second class has a supertype, the supertype doesn't get put into the actual FunctionType, but it does result in a $jscomp.inherits() call that causes an error if it's incompatible with the first definition's superclass.
It's difficult to do this correctly for ES5-style classes because we don't have a single point that declares the class/properties, but prototype properties potentially scattered throughout the code. This could be easier for ES6-style classes because there is a single CLASS node representing the class declaration. We could check for structural compatibility there.
The text was updated successfully, but these errors were encountered:
Yes, this does appear to be a problem (tested here). I would guess the problem might be something like this: somewhere in the closure compiler source code, classes are additive accumulated. Then, the solution is to instead only use the last class assignment to a variable for its properties instead of accumulating the properties.
This doesn't cause any type warnings. The type system merges the properties of the first and second declaration of
C
into a single type.There are certain situations where we do get errors for redefining classes.
FunctionTypeBuilder
throws an error when the constructor signatures are different.If the second class has a supertype, the supertype doesn't get put into the actual FunctionType, but it does result in a $jscomp.inherits() call that causes an error if it's incompatible with the first definition's superclass.
It's difficult to do this correctly for ES5-style classes because we don't have a single point that declares the class/properties, but prototype properties potentially scattered throughout the code. This could be easier for ES6-style classes because there is a single CLASS node representing the class declaration. We could check for structural compatibility there.
The text was updated successfully, but these errors were encountered: