-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async Functions #1781
Closed
Closed
Async Functions #1781
Changes from all commits
Commits
Show all changes
112 commits
Select commit
Hold shift + click to select a range
0a889c6
Added 'async' and 'await' keywords to parser
rbuckton def7460
Adding some tests for 'async'
rbuckton 96c44b3
Added async/await to checker
rbuckton d51b8bd
Added factory, rewriter, and emit for generated nodes.
rbuckton bf28560
Renamed BodyGenerator to CodeGenerator, removed offsets from Exceptio…
rbuckton a60cd3a
Merge 'master' to 'prototypeAsync'
rbuckton 1f190ba
- cleaned up rewriter
rbuckton f8bbe78
Fixed whitespace in Jakefile
rbuckton ead809b
merged 'master' to 'prototypeAsync'
rbuckton 4fad214
Fix for breaks following merge
rbuckton 7c8fd3d
Fix for labels, emitGeneratedNode indentation, and bugs in emit outpu…
rbuckton 4dac41a
rewrite of function parameters with initializers and fixed capturing …
rbuckton 389962b
Merge branch 'master' into prototypeAsync
rbuckton d2bdf6e
Added additional diagnostics around __awaiter and __generator and cha…
rbuckton a8c8918
Tests for async/await, plus bugfixes
rbuckton dc2e6bd
Added updated reference files for test cases
rbuckton 938e0cd
More tests, cleanup for code generator, switched to mechanism for cre…
rbuckton 868cf6d
fix for type check of reserved identifiers in compiler.
rbuckton 6c3eace
Refactored generated locals to a separate object, some work to preser…
rbuckton 1488944
Fixed comment emit for nodes inside of a generated node.
rbuckton cb4bc4f
More cleanup for comment preservation
rbuckton faaf778
Updated tests, fix for variable statement emit
rbuckton cfdb9ac
centralized getPromiseConstructor to checker.ts
rbuckton 4ade643
Updated sourcemap output for generated nodes
rbuckton 155b9a5
cleaned up generated code
rbuckton 38d2218
Updated test baselines, fixed error in for..in rewrite
rbuckton 1de7be3
First pass at merge from master
rbuckton 18c2d50
Fixed diagnostic message numbering, updated some baselines
rbuckton 26c6b80
Updated baselines from master
rbuckton a097c2b
Updated baselines
rbuckton b4f21c4
Test fixes, Added AsyncParameter parser context, updated baselines
rbuckton be9653b
Merged generated locals between async/await and destructuring
rbuckton f330910
Added emitYieldExpression to emitter to support async/await in ES6 mode.
rbuckton de210f0
Fixed undefined reference check in checkAwaitableReturnType
rbuckton 701b19d
Simplified creation of IPromise/IPromiseConstructor types in checker
rbuckton 0b0703b
Allow return type inference for async functions when Promise<T> is in…
rbuckton 28799ab
Merge branch 'master' into prototypeAsync
rbuckton 8f3dd8c
Fixed nodeIsMissing test to fix emit output for generated functions
rbuckton c533514
Centralized visitor and some cleanup.
rbuckton a0adf6f
Fixed label numbering in generator
rbuckton ae6a2af
Fix for bug in createTypeChecker
rbuckton ecfbd97
Updated test baselines for async functions
rbuckton dc2a8d0
Fixed label numbering
rbuckton 7b39c80
Fixed var declarations and marked some errors as early errors.
rbuckton bad02ab
Cleaned up generated output, reduced emit of unnecessary statements
rbuckton aba2aed
Fixed import reference for promise constructor across multiple files
rbuckton ecb8f9e
Fixed indentation for __generator
rbuckton 98378d1
Fixed return for factory.updateThrowStatement
rbuckton 0221763
Updated __generator emit to match spec proposal
rbuckton 53c5d26
Removed three unnecessary array allocations in __generator and update…
rbuckton 6185092
Add support for parameter and variable destructuring in async functions
rbuckton c88dce4
Fixed order of operations during emit for await in a BindingPattern i…
rbuckton e4a808c
Cleaned up destructuring for BindingElement and added rewrite for des…
rbuckton a1b29e5
Removed unused function
rbuckton a62ea04
Rewrite for SpreadElementExpression
rbuckton b042658
Fixed bug in spread element rewrite, updated test baselines
rbuckton 69c16b4
Added script to generate most of Factory and Visitor
rbuckton bd98edb
Renamed syntax.json
rbuckton b4d5e0d
Migrate emitter to use rewrite methods for destructuring/spread element
rbuckton 1aafc40
Removed emitDestructuring function
rbuckton 38a95f1
Fixed emit for parenthesized expressions, fixed rewrite for destructu…
rbuckton 3e30ed1
Updated baseline for destructuring
rbuckton 70023dc
Added test cases for es6 emit
rbuckton c21918c
Additional typecheck for yield
rbuckton 20aab8e
Fixed bug for "yield*" in __generator
rbuckton 0a7270e
Add visitor handler for Identifier
rbuckton 4101450
Fixed rewrite for labeled statement, for in, yield*, and variable dec…
rbuckton efc2809
Added new tests for es6 and binding elements in es5/3
rbuckton f100bfc
Added capture for lexical arguments in async function
rbuckton 8a90e27
Fixed break/continue in labeled loop, switched to literal numbers for…
rbuckton 75e1de6
Updated baselines for async tests
rbuckton 5b005f6
Merge branch 'master' into prototypeAsync
rbuckton 20a9a6c
Merge branch 'prototypeAsync' from rbuckton/TypeScript into prototype…
rbuckton cefeaf0
Cleaned up whitespace
rbuckton 1d1f784
Fix when global IPromise and IPromiseConstructor types are not found.
rbuckton 525b7d2
Added support for `await` in `with`
rbuckton fa1f495
Simplified visitor implementation
rbuckton 7491a72
Functional style for generated locals
rbuckton a46fa3c
Refactored rewriter and visitor to functional style, updated test bas…
rbuckton 8d60e54
Refactor code generation and rewriters to remove closures
rbuckton 276ce4f
Using generic error message for checkAsyncModifier
rbuckton 1aca763
factory generator cleanup
rbuckton e5a5886
more factory generator cleanup
rbuckton b5e1efc
more factory generator cleanup and updated baselines for diagnostic m…
rbuckton d8b2373
Fixed generics on IPromiseConstructor, fixed type check and errors fo…
rbuckton d059142
Clarified error message for promise constructor collision
rbuckton 95de399
Fixed issue with while/do loop in try/catch, simplified and updated _…
rbuckton 635edca
Updated const numbering for endfinally, downlevel async behind a flag…
rbuckton 0450937
Updated tslib.js to UMD, added tslib.d.ts
rbuckton 4c855df
switched from compilerOptions.target to languageVersion
rbuckton 04b19a0
Refactor common patterns around GeneratorParameter and AsyncParameter
rbuckton 5340f0c
emit 'await' expression as fallback when there are checker errors.
rbuckton 4ac9c35
Added factory, generator, and rewriter to tsconfig.json
rbuckton 2b14c43
Update baselines from parser changes.
rbuckton 195c64e
Further restrictions to disallow async modifier in an accessor
rbuckton 0560e77
Updated baselines for parser changes.
rbuckton 866fba7
Relaxed parsing restriction for 'await' keyword to align with treatme…
rbuckton 86021eb
More consistent handling of ParserContextFlags for Parameters, Bindin…
rbuckton 2e4a614
conformance tests for await in binding element and spread element
rbuckton 22eda41
Fixed await in spread element, added conformance tests
rbuckton 5a34605
Update baselines for spread element, minor revision to rewriteCallExp…
rbuckton aaa122b
Changed visitVariableDeclaration to emit an identifier with no source…
rbuckton c8ec582
Merge branch 'master' to prototypeAsync
rbuckton dd6bc44
Added missing dependency to Jakefile for tslib
rbuckton e1bc0bd
Added error when unable to infer a return type as a Promise for an as…
rbuckton 7f6ea09
Merge branch 'prototypeAsync' of https://github.com/Microsoft/TypeScr…
rbuckton 763edc6
A number of updates based on CR feedback
rbuckton ab3f342
Merge branch 'master' into prototypeAsync
rbuckton aece9ae
Fixed error in colorization.ts in unit tests after recent change to s…
rbuckton 4c132c9
Fixes for PR comments and updated baselines.
rbuckton 60a0a49
Various updates from PR feedback.
rbuckton d57fe72
Updated LKG
rbuckton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's tslib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An experimental feature we are adding to support async functions in ES5 and earlier. Instead of emitting the
__extends
,__awaiter
, and__generator
functions directly in the output file, the developer can instead include a 'tslib.js' file that contains those functions.tslib.js uses a UMD (Universal Module Dependency) -like approach that makes those functions available on the global when loaded via
<script>
, or as exported functions when loaded either with CommonJS or AMD. In addition, when importing tslib in Common JS or AMD, you can choose to call a specialinstall
exported function that installs the helper methods on the global object.This is an advanced feature and currently experiemental. If a developer choses to use tslib.js, they may pass the
--noHelpers
(experimental) command line option to tsc and it will not emit the helper methods to any file.For example:
Or: