Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Playground errors when serializing logs #3168

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions packages/playground/src/sidebar/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,23 @@ function rewireLoggingToElement(
}

function produceOutput(args: any[]) {
let result: string = args.reduce((output: any, arg: any, index) => {
const textRep = objectToText(arg)
const showComma = index !== args.length - 1
const comma = showComma ? "<span class='comma'>, </span>" : ""
return output + textRep + comma + " "
}, "")

Object.keys(replacers).forEach(k => {
result = result.replace(new RegExp((replacers as any)[k], "g"), k)
})

return result
try {
let result: string = args.reduce((output: any, arg: any, index) => {
const textRep = objectToText(arg)
const showComma = index !== args.length - 1
const comma = showComma ? "<span class='comma'>, </span>" : ""
return output + textRep + comma + " "
}, "")

Object.keys(replacers).forEach(k => {
result = result.replace(new RegExp((replacers as any)[k], "g"), k)
})

return result
} catch (error) {
console.warn(i("play_run_log_fail"), error)
return i("play_run_log_fail")
}
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/typescriptlang-org/src/copy/en/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const playCopy = {
play_run_js: "Executed JavaScript",
play_run_ts: "Executed transpiled TypeScript",
play_run_js_fail: "Executed JavaScript Failed:",
play_run_log_fail: "Failed to serialize log",
play_default_code_sample: `// Welcome to the TypeScript Playground, this is a website
// which gives you a chance to write, share and learn TypeScript.

Expand Down