Proposal to add symbol: "hasInstanceStrict"

T.J. Crowder tj.crowder at
Wed Feb 21 07:50:14 UTC 2018

On Wed, Feb 21, 2018 at 5:15 AM, Александр Ефремов <mr.efrem at>
> I don’t understand how it will be comfortable to write
> decorators for checking arguments of every function with
> different set of arguments:
> ```
> function a(b: PrimitiveNumber) {}
> function a1({ x: PrimitiveBoolean, d: PrimitiveString }) {}
> function a2(e: PrimitiveString, { f: PrimitiveNumber, g: PrimitiveString
}, j: PrimitiveBoolean) {}
> ```

You wouldn't. See my `@rttc` example earlier, it would be something like:

function a(b) {}

@rttc({ x: PrimitiveBoolean, d: PrimitiveString })
function a1({ x, d }) {}

@rttc(PrimitiveString, { f: PrimitiveNumber, g: PrimitiveString },
function a2(e, { f, g }, j) {}

Or perhaps the decorations go on the parameters (avoiding the repetition of
names in the destructuring above), in which case I probably would have a
decorator per typecheck (but the great thing with it being general is you
could choose a parameterized decorator instead):

function a(@primitiveNumber b) {}

function a1({ @primitiveBoolean x, @primitiveString d }) {}

function a2(@primitiveString e, { @primitiveNumber f, @primitiveString g },
@primitiveBoolean j) {}

On Wed, Feb 21, 2018 at 5:26 AM, Aleksander Efremov <mr.efrem at>
> I offered use syntax which a lot of developers already know and it
> would be intuitively clear to use it.

It also conflicts with TypeScript's static types (it looks identical, does
something different), so I don't see that being adopted.

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

More information about the es-discuss mailing list