Proposal to add symbol: "hasInstanceStrict"

Mike Samuel mikesamuel at
Sun Feb 18 17:43:16 UTC 2018

Must hasInstanceStrict's parameter remain untyped for a guard to complete
or is there a top type with an unguarded hasInstanceStrict that these
checks bottom out on?

"has" to my ear sounds like it should return a boolean.  Maybe "require."

On Feb 18, 2018 11:30 AM, "Aleksander Efremov" <mr.efrem at> wrote:

It’s attempt to provide intermediate layer for implementation of runtime
type checking.

class PrimitiveNumber {
        static [Symbol.hasInstanceStrict](x) {
                if (typeof x !== ’number’) {
                        throw new TypeError(‘Invalid type’);

function sum(a: PrimitiveNumber, b: PrimitiveNumber) {
        return a + b;

const c: PrimitiveNumber = sum(1, 2);

I.e. when appears assignment of variable (const) if then follows `:
<class>` then JS runtime must to call method `static
[Symbol.hasInstanceStrict](x)` and transfer to there assignable value.

es-discuss mailing list
es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list