Proposal: Optional Static Typing (Part 3)

Michał Wadas michalwadas at
Mon Jan 15 11:11:48 UTC 2018

> Part of this has had me considering if freezing classes (and all
recursively referenced types) used in the type system is viable.

function foo(bar: Array.<Set>) {

[Array, Set] = [Set, Array];
foo(new Array([Set()]));

You can't freeze all builtins for obvious reasons.

You totally omitted point that your type system can't use or describe this

function issue(Ctor) {
   assert(Reflect.isConstructor(Ctor)); // Type system don't provide way to
disguintish object with [[Construct]] and [[Call]] methods.
   assert(Foo.isPrototypeOf(Ctor)); // Type system don't provide way to
ensure prototypal inheritance
   const retClass = class extends Ctor { // Type system don't provide way
to describe types being returned from function
   Object.assign(retClass.prototype, mixin); // Object.assign can be
overridden to do anything, so actual code execution is required to prove
it's valid
   return retClass;

TypeScript favors OOP because it supports virtually all OOP idioms, but
doesn't support non-basic FPP idioms.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list