{"action":"created","issue":{"url":"https://api.github.com/repos/TypeStrong/ts-node/issues/245","repository_url":"https://api.github.com/repos/TypeStrong/ts-node","labels_url":"https://api.github.com/repos/TypeStrong/ts-node/issues/245/labels{/name}","comments_url":"https://api.github.com/repos/TypeStrong/ts-node/issues/245/comments","events_url":"https://api.github.com/repos/TypeStrong/ts-node/issues/245/events","html_url":"https://github.com/TypeStrong/ts-node/issues/245","id":193238635,"number":245,"title":"Top-level await support in REPL","user":{"login":"aseemk","id":537838,"avatar_url":"https://avatars.githubusercontent.com/u/537838?v=3","gravatar_id":"","url":"https://api.github.com/users/aseemk","html_url":"https://github.com/aseemk","followers_url":"https://api.github.com/users/aseemk/followers","following_url":"https://api.github.com/users/aseemk/following{/other_user}","gists_url":"https://api.github.com/users/aseemk/gists{/gist_id}","starred_url":"https://api.github.com/users/aseemk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aseemk/subscriptions","organizations_url":"https://api.github.com/users/aseemk/orgs","repos_url":"https://api.github.com/users/aseemk/repos","events_url":"https://api.github.com/users/aseemk/events{/privacy}","received_events_url":"https://api.github.com/users/aseemk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-02T22:59:26Z","updated_at":"2016-12-02T23:02:19Z","closed_at":null,"body":"Hey there,\r\n\r\nGreat work on ts-node! I just looked through the code a bit, and you all have clearly put a lot of thought and time into it. Thank you.\r\n\r\nOne request: I love using the REPL for quick exploration/experimentation/learning. And that often involves async steps, e.g. DB queries or API requests.\r\n\r\nBefore TypeScript, we used to use [Streamline.js](https://github.com/Sage/streamlinejs), and I loved that its REPL supported making async calls and awaiting their responses:\r\n\r\n```\r\n$ _node\r\n_node> fs.stat('/dev/null', _)\r\n{ dev: 1011986504, ... }\r\n_node> r.get('https://httpbin.org/ip', _).body\r\n'{\\n  \"origin\": \"1.2.3.4\"\\n}\\n'\r\n_node> ...\r\n```\r\n\r\nI understand that TypeScript and ES6/7 as languages don't allow top-level `await` in modules, but would you be open to supporting that in the REPL?\r\n\r\nThe way the Streamline REPL does it is simply by wrapping the code in an async IIFE, and only calling the REPL `eval` callback once the async IIFE finishes:\r\n\r\nhttps://github.com/Sage/streamlinejs/blob/v2.0.13/lib/repl.js#L23-L42\r\n\r\nThank you in advance for the consideration! Cheers."},"comment":{"url":"https://api.github.com/repos/TypeStrong/ts-node/issues/comments/264585971","html_url":"https://github.com/TypeStrong/ts-node/issues/245#issuecomment-264585971","issue_url":"https://api.github.com/repos/TypeStrong/ts-node/issues/245","id":264585971,"user":{"login":"blakeembrey","id":1088987,"avatar_url":"https://avatars.githubusercontent.com/u/1088987?v=3","gravatar_id":"","url":"https://api.github.com/users/blakeembrey","html_url":"https://github.com/blakeembrey","followers_url":"https://api.github.com/users/blakeembrey/followers","following_url":"https://api.github.com/users/blakeembrey/following{/other_user}","gists_url":"https://api.github.com/users/blakeembrey/gists{/gist_id}","starred_url":"https://api.github.com/users/blakeembrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blakeembrey/subscriptions","organizations_url":"https://api.github.com/users/blakeembrey/orgs","repos_url":"https://api.github.com/users/blakeembrey/repos","events_url":"https://api.github.com/users/blakeembrey/events{/privacy}","received_events_url":"https://api.github.com/users/blakeembrey/received_events","type":"User","site_admin":false},"created_at":"2016-12-02T23:02:19Z","updated_at":"2016-12-02T23:02:19Z","body":"Off then top of my head, I don't think it's possible to support without more hacking of the TypeScript compiler and/or into the future with ES6 modules. You need an async function for await for await to compile, but you can't import from inside a function (it must be at the top-level). Happy to keep the issue open though."}}
{"actor":{"display_login":"blakeembrey"}}