mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 13:51:19 +03:00
parent
8afa3413ea
commit
196740cdcd
@ -137,6 +137,17 @@ impl Syntax {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn optional_chaining(self) -> bool {
|
||||
match self {
|
||||
Syntax::Es(EsConfig {
|
||||
optional_chaining: true,
|
||||
..
|
||||
})
|
||||
| Syntax::Typescript(TsConfig { .. }) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dynamic_import(self) -> bool {
|
||||
match self {
|
||||
Syntax::Es(EsConfig {
|
||||
@ -361,6 +372,9 @@ pub struct EsConfig {
|
||||
#[serde(default)]
|
||||
pub nullish_coalescing: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub optional_chaining: bool,
|
||||
|
||||
/// Stage 3.
|
||||
#[serde(default)]
|
||||
pub import_meta: bool,
|
||||
|
@ -888,7 +888,7 @@ impl<'a, I: Tokens> Parser<'a, I> {
|
||||
}
|
||||
|
||||
let is_optional_chaining =
|
||||
self.input.syntax().typescript() && is!('?') && peeked_is!('.') && eat!('?');
|
||||
self.input.syntax().optional_chaining() && is!('?') && peeked_is!('.') && eat!('?');
|
||||
|
||||
/// Wrap with optional chaining
|
||||
macro_rules! wrap {
|
||||
|
Loading…
Reference in New Issue
Block a user