Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    BUG (?): smartclient.d.ts and ISC_Core.js not supporting strict mode / typescript

    I am working on improving the tooling around our js development (no GWT), all the modern tools are running in strict mode and reporting failures when I try to import even the basic SC dependencies.

    Would be great to have typescript with SC components, but I end up with this error:
    Code:
    Failed to compile.
    
    ./src/smartclient.d.ts
    SyntaxError: C:\Users\lpolvani\Desktop\smarclient-cra\src\smartclient.d.ts: Binding 'eval' in strict mode (1125:9)
    
      1123 | * @param {string} Expression to evaluate
      1124 | */
    > 1125 | function eval(expression:string):any;
           |          ^
      1126 | /**
      1127 | *  Shorthand for new Date().getTime();, this returns a timeStamp - a large number
      1128 | *  which is incremented by 1 every millisecond. Can be used to generate unique identifiers,
    It would also be beneficial to import the ISC_* dependencies so webpack can optimize them along with the rest of the application, but instead:
    (those are the first two, but the idea
    Code:
    Failed to compile.
    
    ./src/modules-debug/ISC_Core.js
      Line 6343:17:  Parsing error: 'with' in strict mode
    
      6341 | 
      6342 |             if (evalArgs) {
    > 6343 |                 with (evalArgs) {
           |                 ^
      6344 |                     if (globalScope) returnVal = window.eval(expression)
      6345 |                     else returnVal = eval(expression);
      6346 |                 }
    Code:
    ./src/modules-debug/ISC_Core.js
      Line 119148:62:  Parsing error: Legacy octal literals are not allowed in strict mode
    
      119146 |         var callerFunc = isc.Class.getPrototype().setLogFailureText.caller || arguments.callee.caller,
      119147 |             callerName = callerFunc.name || isc.Func.getName(callerFunc, true),
    > 119148 |             logSlot = callerName.replace(/^.*[_]+([^_]+)/, "\137$1" ) + "Log";
             |                                                              ^
      119149 |         if (isc.AutoTest[logSlot]) return; // initial reporter has primacy
      119150 |         isc.AutoTest[logSlot] = this._getLogFailureText(locator, start, finish);
      119151 |     },
    Code:
    Failed to compile.
    
    ./src/modules-debug/ISC_Core.js
      Line 221:5:      'OpenAjax' is not defined                                              no-undef
      Line 229:5:      'OpenAjax' is not defined                                              no-undef
      Line 1984:17:    Unexpected use of 'location'                                           no-restricted-globals
      Line 2046:17:    Unexpected use of 'location'                                           no-restricted-globals
      Line 2319:88:    Unexpected use of 'screen'                                             no-restricted-globals
      Line 2319:108:   Unexpected use of 'screen'                                             no-restricted-globals
      Line 6553:32:    Unexpected use of 'location'                                           no-restricted-globals
      Line 12469:1:    Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 25484:1:    Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 27020:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 30593:17:   Unexpected use of 'confirm'                                            no-restricted-globals
      Line 35483:9:    Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 44485:89:   Unexpected use of 'location'                                           no-restricted-globals
      Line 46264:39:   Unexpected use of 'screen'                                             no-restricted-globals
      Line 46270:40:   Unexpected use of 'screen'                                             no-restricted-globals
      Line 46307:9:    Unexpected use of 'history'                                            no-restricted-globals
      Line 46310:9:    Unexpected use of 'history'                                            no-restricted-globals
      Line 46627:27:   Unexpected use of 'confirm'                                            no-restricted-globals
      Line 47155:38:   'ActiveXObject' is not defined                                         no-undef
      Line 47164:30:   'ActiveXObject' is not defined                                         no-undef
      Line 47344:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 47494:25:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 47820:37:   'ActiveXObject' is not defined                                         no-undef
      Line 47898:13:   'CollectGarbage' is not defined                                        no-undef
      Line 47915:36:   Unexpected use of 'location'                                           no-restricted-globals
      Line 54093:9:    Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 60169:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 61307:17:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 61586:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 61657:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 62148:29:   Unexpected use of 'location'                                           no-restricted-globals
      Line 62152:70:   Unexpected use of 'location'                                           no-restricted-globals
      Line 62181:14:   Unexpected use of 'location'                                           no-restricted-globals
      Line 78981:9:    Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 80992:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 81162:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 81387:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 81651:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 81666:13:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 94878:21:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 97521:9:    Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 97534:9:    Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 100038:9:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 100039:9:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 100053:9:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 104880:13:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
      Line 119442:21:  Expected an assignment or function call and instead saw an expression  no-unused-expressions


    #2
    Please see our TypeScript docs - you can write your application code in TypeScript, and get all the IDE benefits of code completion and error checking, etc, but the framework itself is not TypeScript and not strict mode compatible.

    Unfortunately strict mode would make it impossible to offer a variety of features, including enhanced stack traces and other debugging information, observation of arbitrary methods, aspects of the class system that are superior to ES6 classes (Super(), mixins), workarounds for various browser bugs, etc (it's a long list). But this has no impact on your productivity with SmartClient (in fact it's the reverse - we offer features you can't implement in strict mode).

    There is also no point in running the core code files through WebPack, as they are already optimized, and it would be a very very bad idea to consolidate them into a single file. See this overview to understand the best delivery approaches - using the FileLoader to precache is really key, and we recommend doing this on the login page. This makes a much larger difference in performance than anything you'll get out of WebPack.

    Note you also seem to have found bugs in WebPack - it thinks a regex is an octal literal - surprising.

    Comment


      #3
      Just by way of analogy: if you are writing a Linux application, you can’t expect the Linux Kernel to conform to coding standards you might use for an app.

      The SmartClient core is like the kernel. Down in the kernel, we need to do different things, and do them faster, as well as work around hardware bugs in ways that would make application developers blanch!

      Comment

      Working...
      X