scriptsharp
scriptsharp copied to clipboard
Logic Bug - 0.8
The following piece of ScriptSharp code is getting translated into javascript which doesn't retain the correct logic:
//C# code SyncData sync = (!Script.IsUndefined(GlobalVariables.SyncData)) ? GlobalVariables.SyncData : null;
//Javascript var sync = (!window.SyncData === undefined) ? window.SyncData : null;
Even when GlobalVariables.SyncData is a valid object the above code assigns null.
Where as if the ! is moved outside brackets the correct logic is given:
//C# code SyncData sync = !(Script.IsUndefined(GlobalVariables.SyncData)) ? GlobalVariables.SyncData : null;
//Javascript var sync = (!(window.SyncData === undefined)) ? window.SyncData : null;
Looks like a good catch - a missing case of parentheses needed scenario. Will get to it.
Meanwhile, I'd actually recommend using this:
SyncData sync = Script.Value<SyncData>(GlobalVariables.SyncData, null);
It should generate:
var sync = window.SyncData || null;
Fix is in ... will include in next preview build.