Ugi
05/18/2020, 5:44 PMjs("...")
code block. In pre 1.4 I had this code to determine if I'm running on node or in browser (it's inside an actual implementation of expected method in multi platform project)
val runningOnNode = js(
"if (typeof window === 'undefined') {\n" +
" true;\n" +
" } else {\n" +
" false;\n" +
" }"
)
Since switching to 1.4 and enabling IR, that block started returning undefined
where it was previously a boolean true or false. I worked around this with this:
val runningOnNode = js(
"var isNode = false;\n" +
"if (typeof window === 'undefined') {\n" +
" isNode = true;\n" +
" } else {\n" +
" isNode = false;\n" +
" }\n" +
"return isNode;"
)
So I have two questions, and please consider that my JS knowledge is very limited:
1. Is this expected change that came with 1.4 or is it a bug?
2. Am I using js(...)
code block in a way that it was not meant to be used, and causing the issue myself?turansky
05/18/2020, 6:08 PMval isNode:Boolean = jsTypeOf(window) == "undefined"
Ugi
05/18/2020, 6:28 PMgildor
05/19/2020, 3:54 AM"""some multiline code"""
to avoid all those \n and concatenationsgildor
05/19/2020, 4:04 AM