News for hackers. Stuff that matters.
Re:JavaScript for People Who Hate JavaScript by Zolomon on Wednesday August 09, 2017 @05:42AM (#14966957)
I wager there is type inference going on and that the IDE will supply red squiggly lines beneath the expression if the author were to supply something that would not one way or the other convert to the types that source can consume.
Re:JavaScript for People Who Hate JavaScript by virtualwhys on Wednesday August 09, 2017 @10:29AM (#14969257)
> I wager there is type inference going on

What will the compiler infer other than a value of type string?

> to supply something that would not one way or the other convert to the types that source can consume.

Well, clearly `source` takes a string, so it will happily accept "produckname" and blow up at run time.

Short of macros I know of no other compile time mechanism that would enable "safe" strings. The usual workaround is to not use plain string values at all and wrap in a sealed type.

Re:JavaScript for People Who Hate JavaScript by cel1ne on Wednesday August 09, 2017 @06:52AM (#14967327)
It maps to database fields. The compiler checks that it's a string, but the rest is done by `admin-on-rest`'s mapping.