refactor(es/parser): Simplify logic (#4329)

This commit is contained in:
Pig Fang 2022-04-14 08:50:54 +08:00 committed by GitHub
parent ed2674f106
commit 37aec5b199
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -909,7 +909,13 @@ impl<I: Tokens> Parser<I> {
}
let check_type = ty;
let extends_type = p.parse_ts_non_conditional_type_within_ctx()?;
let extends_type = {
p.with_ctx(Context {
disallow_conditional_types: true,
..p.ctx()
})
.parse_ts_non_conditional_type()?
};
expect!(p, '?');
@ -929,14 +935,6 @@ impl<I: Tokens> Parser<I> {
})
}
fn parse_ts_non_conditional_type_within_ctx(&mut self) -> PResult<Box<TsType>> {
self.with_ctx(Context {
disallow_conditional_types: true,
..self.ctx()
})
.parse_ts_non_conditional_type()
}
/// `tsParseNonConditionalType`
fn parse_ts_non_conditional_type(&mut self) -> PResult<Box<TsType>> {
trace_cur!(self, parse_ts_non_conditional_type);