TypeError: Assignment to constant variable
callum-atwal opened this issue · 4 comments
I was building my Angular application for production use where I ran into this weird issue (after some research, it turns out it isn't uncommon for production builds to have, what appears to be, breaking differences for both React and Angular - I suspect the same may apply for other frameworks).
It complains about the _docUpdateHandler
function saying it is assigning something to a constant variable.
Line 355 in 97df715
The only const I could see defined was on line 355 so I changed this to a let
and the issue went away. This seems odd since this encoder
variable is only being passed through to those other preceding functions.
It might be something worth looking into. Since I'm submitting my work, I'm making these hacky edits - limited by time to investigate this any further but thought I'd raise the issue if there is one that I'm not seeing :D
This is a very strange issue and thanks for reporting it. Module bundlers really do weird stuff sometimes.
I'm pretty certain that the types and variable declarations are correct. The only problematic use of const
I could find was here:
Line 193 in 97df715
Even though it is bad style, it is correct JavaScript because the variables are scoped. Did you change the variable declarations there too? Because, I don't see any reason for a problem in line 355.
Nope, I had only changed Line 355. I too was positive it was correct. Angular's build optimizer seemed to disagree :(
I renamed the encoder variable. Can you try and see if this also fixes the problem? My linter complains when I change the declaration type, so I'm looking for other ways to fix this problem.
I just published y-webrtc@10.1.4
, could you please update your dependency and check if this fixes the problem?
So I've realised a few things since raising this issue. I've been using slightly older versions of your modules since I've got an Angular v7 app which doesn't support the latest TypeScript (which consequently I think recent versions of yjs require a certain version of TypeScript - I'll raise this in the yjs repo as a potential issue)
I forked the y-webrtc repo, and oddly, Angular no longer complains with the same code? Very odd stuff going on but it's probably something I have done rather than the y-webrtc module. I'll close this issue :D