Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Running Code Samples #8

Open
gcrev93 opened this issue Aug 27, 2019 · 2 comments
Open

Running Code Samples #8

gcrev93 opened this issue Aug 27, 2019 · 2 comments

Comments

@gcrev93
Copy link

gcrev93 commented Aug 27, 2019

When selecting the 'Try' button and opening TypeScript playground (or simply copy and pasting the code locally), running some of the code samples does not allow users to see the results of the code (thinking in terms of beginners or those trying to get more of an understanding).

Suggestion: Update TS code samples to actually call functions created in code samples:

function printAll(strs: string | string[] | null) {
    if (typeof strs === "object") {
        for (const s of strs) {
            console.log(s)
        }
    }
    else if (typeof strs === "string") {
        console.log(strs)
    }
    else {
        // do nothing
    }
}

to

function printAll(strs: string | string[] | null) {
    if (typeof strs === "object") {
        for (const s of strs) {
            console.log(s)
        }
    }
    else if (typeof strs === "string") {
        console.log(strs)
    }
    else {
        // do nothing
    }
}

printAll("just wanna see something")
@gautamsingal
Copy link

Hey, @gcrev93 Just wanted to provide some feedback here. How about when we click on Try, rather than opening the URL, it runs the code there itself to show results. May be using iframe. That will help in not navigating away from the page. If not an iframe then maybe open up the link in a new tab. The idea behind is to make sure the user is not taken away from the handbook.

@orta
Copy link
Contributor

orta commented Jun 19, 2020

We're probably gonna stick with sending folks to the playground in a new window when it moves to the website, getting a copy of the compiler and any deps to run the JS is about 8MB of downloads and just not worth the extra bandwidth when we can have it running in the playground

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants