Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1155,12 +1155,12 @@ namespace ts {
if (token === SyntaxKind.ExportKeyword) {
nextToken();
if (token === SyntaxKind.DefaultKeyword) {
return lookAhead(nextTokenIsClassOrFunction);
return lookAhead(nextTokenIsClassOrFunctionOrAsync);
}
return token !== SyntaxKind.AsteriskToken && token !== SyntaxKind.AsKeyword && token !== SyntaxKind.OpenBraceToken && canFollowModifier();
}
if (token === SyntaxKind.DefaultKeyword) {
return nextTokenIsClassOrFunction();
return nextTokenIsClassOrFunctionOrAsync();
}
if (token === SyntaxKind.StaticKeyword) {
nextToken();
Expand All @@ -1182,9 +1182,9 @@ namespace ts {
|| isLiteralPropertyName();
}

function nextTokenIsClassOrFunction(): boolean {
function nextTokenIsClassOrFunctionOrAsync(): boolean {
nextToken();
return token === SyntaxKind.ClassKeyword || token === SyntaxKind.FunctionKeyword;
return token === SyntaxKind.ClassKeyword || token === SyntaxKind.FunctionKeyword || token === SyntaxKind.AsyncKeyword;
}

// True if positioned at the start of a list element
Expand Down Expand Up @@ -5070,7 +5070,7 @@ namespace ts {
* In such situations, 'permitInvalidConstAsModifier' should be set to true.
*/
function parseModifiers(permitInvalidConstAsModifier?: boolean): ModifiersArray {
let flags = 0;
let flags: NodeFlags = 0;
let modifiers: ModifiersArray;
while (true) {
const modifierStart = scanner.getStartPos();
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ namespace ts {
}

export interface ModifiersArray extends NodeArray<Modifier> {
flags: number;
flags: NodeFlags;
}

// @kind(SyntaxKind.AbstractKeyword)
Expand Down
18 changes: 18 additions & 0 deletions tests/baselines/reference/exportDefaultAsyncFunction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//// [exportDefaultAsyncFunction.ts]
export default async function foo(): Promise<void> {}
foo();


//// [exportDefaultAsyncFunction.js]
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
export default function foo() {
return __awaiter(this, void 0, void 0, function* () { });
}
foo();
8 changes: 8 additions & 0 deletions tests/baselines/reference/exportDefaultAsyncFunction.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=== tests/cases/compiler/exportDefaultAsyncFunction.ts ===
export default async function foo(): Promise<void> {}
>foo : Symbol(foo, Decl(exportDefaultAsyncFunction.ts, 0, 0))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))

foo();
>foo : Symbol(foo, Decl(exportDefaultAsyncFunction.ts, 0, 0))

9 changes: 9 additions & 0 deletions tests/baselines/reference/exportDefaultAsyncFunction.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=== tests/cases/compiler/exportDefaultAsyncFunction.ts ===
export default async function foo(): Promise<void> {}
>foo : () => Promise<void>
>Promise : Promise<T>

foo();
>foo() : Promise<void>
>foo : () => Promise<void>

3 changes: 3 additions & 0 deletions tests/cases/compiler/exportDefaultAsyncFunction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @target: es6
export default async function foo(): Promise<void> {}
foo();