sat icon indicating copy to clipboard operation
sat copied to clipboard

Numeric results in JS are ignored

Open flaki opened this issue 2 years ago • 1 comments

The return value of JavaScript modules returning type Number values is ignored, the result becomes "":

export const run = (input) => {
  return 12345
};
// returns a { "result": "" }

export const run = (input) => {
  return String(12345)
};
// returns a { "result": "12345" }

According to @ospencer:

TypeScript would force you to return a string/object, but nothing forces that in JS. The Reactr API requires a string be return; the wrapper code will handle strings fine and will call JSON.stringify on objects.

flaki avatar Oct 18 '22 19:10 flaki