Aleksander Efremov (2018-02-18T17:19:19.000Z)
If data were received from database or isn't trusted sources and you want
want be sure that they is correct then it's impossible to do with static
type checking.
And also therefore I don't offer to call function before the real case, I
wrote that that check should be executed in runtime, it isn't compiling
stage similar to compiling language.

18 февр. 2018 г. 20:56 пользователь "Michał Wadas" <michalwadas at gmail.com>
написал:

> Runtime type checking isn't widely deployed for many reasons. Programmable
> runtime type checking would be even worse because engine can't just throw
> away function call (only extreme minority of JS function can be proven to
> be pure).
>
> On 18 Feb 2018 5:30 pm, "Aleksander Efremov" <mr.efrem at gmail.com> 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 mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180218/7fe0b770/attachment.html>
mr.efrem at gmail.com (2018-02-18T19:22:19.622Z)
If data were received from database or isn't trusted sources and you
want be sure that they are correct then it's impossible to do with static
type checking.
And also therefore I don't offer to call function before the real case, I
wrote that that check should be executed in runtime, it isn't compilation
stage similar to compiling language.

18 февр. 2018 г. 20:56 пользователь "Michał Wadas" <michalwadas at gmail.com>
написал:
mr.efrem at gmail.com (2018-02-18T19:18:37.563Z)
If data were received from database or isn't trusted sources and you
want be sure that they are correct then it's impossible to do with static
type checking.
And also therefore I don't offer to call function before the real case, I
wrote that that check should be executed in runtime, it isn't compiling
stage similar to compiling language.

18 февр. 2018 г. 20:56 пользователь "Michał Wadas" <michalwadas at gmail.com>
написал:
mr.efrem at gmail.com (2018-02-18T19:18:08.149Z)
If data were received from database or isn't trusted sources and you
want be sure that they is correct then it's impossible to do with static
type checking.
And also therefore I don't offer to call function before the real case, I
wrote that that check should be executed in runtime, it isn't compiling
stage similar to compiling language.

18 февр. 2018 г. 20:56 пользователь "Michał Wadas" <michalwadas at gmail.com>
написал: