Proposal to add symbol: "hasInstanceStrict"

Aleksander Efremov mr.efrem at
Mon Feb 19 16:35:37 UTC 2018

How do you offer to check a assignment of result of `fetch` to the variable
(const) ? For it also exists decorator?

19 февр. 2018 г. 18:25 пользователь "T.J. Crowder" <
tj.crowder at> написал:

On Mon, Feb 19, 2018 at 1:59 PM, Александр Ефремов <mr.efrem at>
> A reasons for this proposal:
> 1. I don’t want to use static type checking (Flow or TypeScript)
> because on my experience there more a time spend on the
> describing all types and etc. than it gives favor.
> 2. I want to validate API payloads and other sources of data when
> it’s need.

When [decorators][1] land, provided they land with a means of [decorating
functions][2] (either as part of that proposal or as a follow-on), that
would do the job, wouldn't it? Using your `sum` example:

@rttc(PrimitiveNumber, PrimitiveNumber)
const sum = (a, b) => {
    return a + b;

...where `rttc` ("runtime type check") decorates the function such that it
does runtime validation of the type of the arguments supplied. (See the
issue referenced in the second link above for why I used a function
expression rather than declration for `sum`.)

-- T.J. Crowder

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list