You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may lead to subtle correctness bugs. This only happens when there's a newline between the await keyword and the awaited expression. This also only happens for top-level await. Enclosing the await in an async function makes the bug disappear.
quick solution: Limit the reparse to the extent of the original expression. This will prevent duplication but would result in an expression expected error following the await. This is undesirable, but is also no worse than the behavior in 3.9.
good solution: When reparsing, if the extent of the new expression is larger than the original expression, we must also reparse the statement that follows starting at the end position of the new expression. This may take some additional time to implement.
I'm investigating the "good solution" currently, and if it looks like it will take more than the rest of the day to implement I would advise we implement the "quick solution" for the 4.0 beta.
TypeScript Version: Nightly
Search Terms: top-level await newline duplicate duplicated
Code
Expected behavior:
The generated code should only call
foo()
once.Actual behavior:
The generated code calls
foo()
twice:This may lead to subtle correctness bugs. This only happens when there's a newline between the
await
keyword and the awaited expression. This also only happens for top-level await. Enclosing the await in an async function makes the bug disappear.Playground Link: link
Related Issues:
The text was updated successfully, but these errors were encountered: