1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use oxc_syntax::assumptions::CompilerAssumptions;

use crate::{
    es2015::ArrowFunctionsOptions, es2020::NullishCoalescingOperatorOptions,
    react_jsx::ReactJsxOptions,
};

#[derive(Debug, Default, Clone)]
pub struct TransformOptions {
    pub target: TransformTarget,
    pub assumptions: CompilerAssumptions,

    pub react_jsx: Option<ReactJsxOptions>,

    // es2022
    pub class_static_block: bool,
    // es2021
    pub logical_assignment_operators: bool,
    // es2020
    pub nullish_coalescing_operator: Option<NullishCoalescingOperatorOptions>,
    // es2019
    pub optional_catch_binding: bool,
    // es2016
    pub exponentiation_operator: bool,
    // es2015
    pub duplicate_keys: bool,
    pub function_name: bool,
    pub arrow_functions: Option<ArrowFunctionsOptions>,
    pub shorthand_properties: bool,
    pub sticky_regex: bool,
    pub template_literals: bool,
    pub property_literals: bool,
    pub babel_8_breaking: Option<bool>,
    pub instanceof: bool,
    pub new_target: bool,
}

/// See <https://www.typescriptlang.org/tsconfig#target>
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
pub enum TransformTarget {
    ES3,
    ES5,
    ES2015,
    ES2016,
    ES2018,
    ES2019,
    ES2020,
    ES2021,
    ES2022,
    ES2024,
    #[default]
    ESNext,
}