proposal-optional-types
proposal-optional-types copied to clipboard
Should classes be nominally or structurally typed?
(porting comments from an early review from @domenic to github issues)
@domenic: JS is generally structurally typed, so introducing nominal typing sounds awkward.
TODO(@goto, @dimvar): write this up.
@erights: is this (nominal typing) closer to the semantics of the runtime checks, like instanceof?
instanceof is definitely a nominal-like test, not a structural-like one.
Btw, somewhere I heard the following hilarious observation:
Nominal types are about class names. Structural types are about method names.