azerion / phaser-input

Adds input boxes to Phaser like CanvasInput, but also works for WebGL and Mobile, made for Phaser only.
MIT License
201 stars 64 forks source link

The top part of the script gives red error in JSLint #24

Closed bluePlayer closed 7 years ago

bluePlayer commented 7 years ago

I copied the non minimized version of the script in Aptana Studio 3 and turned on JSlint. I cannot execute my other code since this script breaks before it.

What did the author wanted to achieve with this code block:

var __extends = (this && this.__extends) || function (d, b) {'use strict';
    var p;

    for (p in b) {
        if (b.hasOwnProperty(p)) {
            d[p] = b[p];
        }
    }

    function __() { this.constructor = d; }
    d.prototype =
        b === null ?
        Object.create(b) :
        (__.prototype = b.prototype, new __()); // expected an operator and saw new
};
AleBles commented 7 years ago

The Original source files are made in TypeScript. This little piece of code here is created by the compiler, and used for inheritance.

Ideally you shouldn't Lint compiled libraries in your project. I do however think that Linting is an important process and therefor we have added TSlint in this library, so we can still lint the original sources.

bluePlayer commented 7 years ago

You are using the official Typescript compiler? And this compiler converts to JS with fake inheritance? :D Dear God, JS does not have classical inheritance. And also the other part of the library contains rather bad JavaScript, no offence.

AleBles commented 7 years ago

You're always welcome to submit a PR if you think there are some improvements needed, nothing is set stone.

bluePlayer commented 7 years ago

Was about to rework the JS code completely with JS best practices. Seems like a promising library. Once I find time and enthusiasm will do so... :)

AleBles commented 7 years ago

You can rework the compiled JS files but those will be overwritten everytime we recompile the stuff. You can also apply most of those practices to the TypeScript source as well, TS runs regular JavaScript as well. Maybe I should start adding contributing guide's to explain the current development process :)

bluePlayer commented 7 years ago

Yes I know that Typescript compiler can understand JS but didn't know that this compiler cannot create good JS code, sadly.

AleBles commented 7 years ago

You're making me curious about which parts of the compiled code are actually so wrong that they annoy you :P

bluePlayer commented 7 years ago

It doesn't annoy me. I would just fix the code above and go with it(if I knew how). But the whole script is based on classical inheritance which doesn't exist in JS and I also see, using the "this" keyword, million times. :) Hard to read.

Using the "var" keyword multiple times in a single function block. No need for that.

Function inside a function, inside a function. No need for such nesting. There can be only one function which creates one library object in the DOM. ;)

Try run the non minimized version in Aptana3/JSlint, you will see red lines but also lot of warnings. ;)

bluePlayer commented 7 years ago

Perhaps there are some options to choose in the Typescript compiler. Is it compiling with strict mode on?