When running in Node, this line will cause ReferenceError: File is not defined:
---- Elm 0.19.0 ----------------------------------------------------------------
Read <https://elm-lang.org/0.19.0/repl> to learn more: exit, help, imports, etc.
--------------------------------------------------------------------------------
> type alias Test = { bla : Int }
> Test 1
ReferenceError: File is not defined>
This error can also be seen when using elm-test.
Maybe File can be added here in node-test-runner? https://github.com/rtfeldman/node-test-runner/blob/master/templates/before.js
It will still not work in the repl though.
I can do the same check as with DataView a couple lines above:
if (typeof File === 'function' && value instanceof File)
{
return _Debug_internalColor(ansi, '<' + value.name + '>');
}
I believe the only ways to get File values are:
Cmd with File.SelectI think that means that it will not be possible to get File values in the REPL, but there may need to be similar checks in elm/file in case people have that as a dependency.
Fix should be available in 1.0.2
This works great. Thank y'all so much for fixing so quickly!
Thank you @doanythingfordethklok for confirming the fix! And thank you @SidneyNemzer for stripping all the extra stuff from the example and showing the line of code. Very helpful!
Also, I am doing an equivalent fix in elm/file because this value instanceof File pattern appears there in the file decoder. So that should be fine soon. But if there are any other problems like this, please let me know.
@evancz I updated elm/json and got the same issue with FileList: https://github.com/elm/json/blob/84ecbaa4d95e936fd67e156aa99dacbb4e91b972/src/Elm/Kernel/Json.js#L331
This test failed because it threw an exception: "ReferenceError: FileList is not defined"
This was polyfilled yesterday by @rtfeldman. So it would occur in previous versions of elm-test, but it's fixed in the current. https://github.com/rtfeldman/node-test-runner/commit/2ed1e38772c28e323f64ba98ddb1c1f54023c2dd#diff-11c235e88b2066e030399d9b03ecc1df
For consistency and repl / serviceworkers it should probably handled the same way as File ;)
@evancz it's the same for FileList in elm/json FYI - we're now polyfilling that in elm-test but it probably affects repl too!
Thank you for letting me know. I made a check for it in 1.1.2 of elm/json.
If there are further problems, please make fresh issues and leave out any winky faces.
Most helpful comment
Thank you @doanythingfordethklok for confirming the fix! And thank you @SidneyNemzer for stripping all the extra stuff from the example and showing the line of code. Very helpful!
Also, I am doing an equivalent fix in
elm/filebecause thisvalue instanceof Filepattern appears there in the file decoder. So that should be fine soon. But if there are any other problems like this, please let me know.