fix(playground): return the string of NaN and Infinity in the playground#505
fix(playground): return the string of NaN and Infinity in the playground#505YonatanKra wants to merge 3 commits into
Conversation
|
@YonatanKra thanks for creating another PR 💪 Can you explain your rationale of fixing this and how this PR was tested? As you have noticed in #367 (comment) neither |
What I did was change how the playground works. It returns a string of Infinity or NaN in case these values are returned (instead of returning a json.stringifyof them. Tested on local playground |
| export async function compileAskCode( | ||
| baseEnvironment: { | ||
| values?: { [p: string]: any }; | ||
| customValues?: { [p: string]: any }; | ||
| resources: { | ||
| [p: string]: Resource<any, any>; | ||
| }; | ||
| }, | ||
| askCode: AskCodeOrValue | ||
| ) { | ||
| let result = await runUntyped(baseEnvironment, askCode, []); | ||
| if ( | ||
| result === Infinity || | ||
| result === -Infinity || | ||
| (typeof result === 'number' && isNaN(result)) | ||
| ) { | ||
| result = result.toString(); | ||
| } | ||
| return result; | ||
| } |
There was a problem hiding this comment.
@mhagmajer this is the "magic". Would it be valid to add this logic to the middleware as well?
mhagmajer
left a comment
There was a problem hiding this comment.
Let's wait for discussion at #367 (comment) to resolve
|
@YonatanKra , I believe we should first finish our discussion in #367 and only after that create any PRs. |
Drafted :) |
Closes #367
See my comment in #367 regarding Infinity and NaN in JSON