feat(es/parser): Enforce orders of override and async (#1670)

Co-authored-by: 강동윤 <kdy1997.dev@gmail.com>
This commit is contained in:
Pig Fang 2021-05-10 16:55:22 +08:00 committed by GitHub
parent de15804b89
commit b713972493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -716,7 +716,13 @@ impl<'a, I: Tokens> Parser<I> {
{
// handle async foo(){}
let is_override = is_override || self.parse_ts_modifier(&["override"])?.is_some();
if self.parse_ts_modifier(&["override"])?.is_some() {
is_override = true;
self.emit_err(
self.input.prev_span(),
SyntaxError::TS1029(js_word!("override"), js_word!("async")),
);
}
let is_generator = eat!(self, '*');
let key = self.parse_class_prop_name()?;

View File

@ -0,0 +1,3 @@
class C extends B {
async override fetch() {}
}

View File

@ -0,0 +1,6 @@
error: 'override' modifier must precede 'async' modifier.
--> $DIR/tests/typescript-errors/class/override-with-async/input.ts:2:9
|
2 | async override fetch() {}
| ^^^^^^^^