This project is read-only.

How about a #typesafe or #allow-unsafe-js directive?

Topics: General, Language Specification
Dec 6, 2012 at 12:08 AM
Edited Dec 6, 2012 at 12:09 AM

There are some things that are very annoying with JavaScript.  For instance this piece of misery:

        if (id = 5) 

Do you see the mistake?  It took me a couple hours.  Yet C# would have flagged the "error" immediately.  Maybe if we had a #typesafe directive that would flag as errors things that are otherwise valid javascript.  Or conversely, maybe a #allow-unsafe-js directive would be better.

Dec 6, 2012 at 1:59 PM

JavaScript developers usually use linting tools like JSLint ( ) or JSHint (my preference - ) to catch these kinds of common errors.

Dec 6, 2012 at 10:06 PM
Edited Dec 6, 2012 at 10:08 PM

The idea was that the directive could do more than simple lint checking.

The directive solves the impedance mismatch between javascript and typesafe code.  For example, it could ensure that 'this.' always meant '_this.' in classes.