proposal-optional-types icon indicating copy to clipboard operation
proposal-optional-types copied to clipboard

Should classes be nominally or structurally typed?

Open samuelgoto opened this issue 8 years ago • 1 comments

(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?

samuelgoto avatar Jul 11 '17 20:07 samuelgoto

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.

erights avatar Jul 11 '17 20:07 erights