In the current implementation, when we run the code below, tslab wait for the asynchronous result of hello() and shows Hello, tslab!.
function hello(): Promise<string> {
return new Promise(done => {
setTimeout(() => {
done('Hello, tslab!');
}, 100);
});
}
hello();
After I created some notebooks (e.g. MNIST with tenworflow.js), I noticed this behavior is a little confusing because hello() shows Hello, tslab!, not Promise(...) and users misunderstand hello() returns string, not Promise<string>.
Also, Chrome dev console, which supports top-level await, shows Promise {<pending>} for hello(). Chrome dev console shows Hello, tslab! when await hello() is executed.
In the current implementation, when we run the code below, tslab wait for the asynchronous result of
hello()
and showsHello, tslab!
.After I created some notebooks (e.g. MNIST with tenworflow.js), I noticed this behavior is a little confusing because
hello()
showsHello, tslab!
, notPromise(...)
and users misunderstandhello()
returnsstring
, notPromise<string>
.Also, Chrome dev console, which supports top-level await, shows
Promise {<pending>}
forhello()
. Chrome dev console showsHello, tslab!
whenawait hello()
is executed.Thus, I think we should stop waiting for the last Promise automatically. We should support top-level awaits instead (https://github.com/yunabe/tslab/issues/16).