Closed
Description
TypeScript Version: nightly (2.0.0-dev.20160705)
The changes in #9445 have caused a breaking change in my code base. This is a pattern that we use very frequently our projects.
The compiled output has also changed and no longer functions as expected. The same error also occurs when using the async
library in the same way (e.g. export default async.map(...)
)
Code
import {async,await} from 'asyncawait';
export default async(() => await(Promise.resolve(1)));
should compile without error and emit:
const asyncawait_1 = require('asyncawait');
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = asyncawait_1.async(() => asyncawait_1.await(Promise.resolve(1)));
but incorrectly emits:
const asyncawait_1 = require('asyncawait');
asyncawait_1.async(() => asyncawait_1.await(Promise.resolve(1)));
Expected behavior:
Compiles without error
Actual behavior:
[ts] Declaration expected
Incorrect compiled output
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
yortus commentedon Jul 6, 2016
Looking at the changes in #9445, it seems that if the next token after
export default
isasync
, then it's treated like a declaration rather than an expression. Butasync
is not a keyword (spec), and a valid expression may begin with anasync
token, as in @Seikho's two examples above.I think
export default <expression>
should be allowed even if the expression is something likeasync.map(...)
orasync(() => {...})
, since these are valid expressions.yortus commentedon Jul 6, 2016
If this makes it into the 2.0 release, it will be a breaking change.
DanielRosenwasser commentedon Jul 6, 2016
Thanks for tracking the regression down @yortus!
Fix #9531: account for async as an contextual keyword when parsing ex…
async
as an contextual keyword when parsing export assignments #9541Merge pull request #9541 from Microsoft/Fix9531
[Transforms] Merge master 07/11 into transform (#9697)