Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
boeckMt opened this issue Feb 20, 2020 · 3 comments
Open

Comments

@boeckMt
Copy link

boeckMt commented Feb 20, 2020

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;
      }
 }
@Knochenmark
Copy link

@boeckMt not sure it's actually a global

a simple var infront seems to do the trick

@boeckMt
Copy link
Author

boeckMt commented Apr 25, 2022

@Knochenmark, yes I used the same trick.

But I think this repo is no longer actively developed. Maybe someone of the forkers is willing to fix bugs.

romdhanisam pushed a commit to romdhanisam/jsonix that referenced this issue Sep 3, 2022
romdhanisam pushed a commit to romdhanisam/jsonix that referenced this issue Sep 3, 2022
Signed-off-by: Samir Romdhani <[email protected]>
romdhanisam pushed a commit to romdhanisam/jsonix that referenced this issue Sep 3, 2022
Signed-off-by: Samir Romdhani <[email protected]>
@romdhanisam
Copy link

@Knochenmark, yes I used the same trick.

But I think this repo is no longer actively developed. Maybe someone of the forkers is willing to fix bugs.

Fixed, PR: #266
To test: https://www.npmjs.com/package/@opentempl/jsonix/v/3.0.0-issues-238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants