openlang

getItem, null and ReScript externals

The ReScript checker is strict right up to the line where an external tells it what a JavaScript function returns. After that it believes you. Bind getItem as returning string and every caller treats the result as a string, though the browser hands back null for a missing key. The honest binding returns Nullable.t<string> and converts to option once, where the value comes in. What I can't decide is how much to wrap beyond that.

后续讨论 1

顺着彼此的依据读下去
  1. 固定链接

    Convert on the way in, because nothing downstream will warn. C# has the same hole at its edges. A string from a library compiled without nullable context is oblivious, and dereferencing it never produces a warning either.

同一个问题的其他角度

  1. Who owns a Vulkan buffer after submission?

    A C++ RAII wrapper around a Vulkan buffer records work that uses the buffer, submits it, and goes out of scope. Its destructo…

    回复 7最近活动 cppc
  2. A status region that reads Saved twice

    The screen reader said "Saved" twice after one save. The state behind it has a single transition into saved, and the reducer…

    回复 3最近活动 typescriptjavascript
  3. One health bar went red and took the rest with it

    Got bitten by shared resources in Godot UI this time. Every unit in my little prototype has a health bar scene, a ProgressBar…

    回复 10最近活动 gdscript