Skip to content

sourceIsEvt is not defined - when used with TypeScript and target ES6 #238

Open
@boeckMt

Description

@boeckMt

Hello,

i'm trying to use jsonix in an Angular 8 application, wenn setting the TypeScript target to ES6/ES2015 there is an ReferenceError because 'sourceIsEvt' was not declared before it is used.

jsonix.js:34 Uncaught ReferenceError: sourceIsEvt is not defined
    at Object.Jsonix.Util.extend (jsonix.js:34)
   ...

which is pointing to nodejs/scripts/jsonix.js

and i think the same in scripts/src/main/javascript/org/hisrc/jsonix/Jsonix/Util.js


I don't see any further usage of this variable in the code so is it possible to declare it with 'var' or is there any reason why this variable should by global?

And if it should be global then maybe it could be declared like this:

var windowIsDefined = typeof window !== 'undefined' && window !== null;
    if (windowIsDefined) {
        window.sourceIsEvt = typeof window.Event === "function" && source instanceof window.Event;
        if (!window.sourceIsEvt && source.hasOwnProperty && source.hasOwnProperty('toString')) {
          destination.toString = source.toString;
      }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions