1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 23:34:47 -05:00

Support top-level-await in TypeScript (#3024)

This commit is contained in:
Ryan Dahl 2019-09-30 12:38:23 -04:00 committed by GitHub
parent 5f7ab4884c
commit ae26a9c7a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View file

@ -567,3 +567,8 @@ itest!(top_level_await {
args: "--allow-read top_level_await.js",
output: "top_level_await.out",
});
itest!(top_level_await_ts {
args: "--allow-read top_level_await.ts",
output: "top_level_await.out",
});

View file

@ -0,0 +1,3 @@
const buf: Uint8Array = await Deno.readFile("hello.txt");
const n: number = await Deno.stdout.write(buf);
console.log(`\n\nwrite ${n}`);

View file

@ -539,6 +539,9 @@ window.compilerMain = function compilerMain(): void {
diagnostics = ts.getPreEmitDiagnostics(program).filter(
({ code }): boolean => {
// TS1308: 'await' expression is only allowed within an async
// function.
if (code === 1308) return false;
// TS2691: An import path cannot end with a '.ts' extension. Consider
// importing 'bad-module' instead.
if (code === 2691) return false;