feat(es/ast): Add EsNext to EsVersion (#6816)

This commit is contained in:
Donny/강동윤 2023-01-15 15:43:10 +09:00 committed by GitHub
parent 4ea0e20ded
commit ff78b8f7e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 2 additions and 55 deletions

View File

@ -1,11 +0,0 @@
{
"jsc": {
"parser": {
"syntax": "typescript",
"dynamicImport": true
},
"externalHelpers": true,
"target": "esnext"
},
"sourceMaps": true
}

View File

@ -21,14 +21,6 @@ fn issue_4390() {
dbg!(&rc); dbg!(&rc);
} }
#[test]
fn issue_1532() {
let res = serde_json::from_str::<Options>(include_str!("issue-1532.json"));
let err = res.expect_err("should fail");
assert!(err.to_string().contains("unknown variant `esnext`"));
}
#[test] #[test]
fn jsonc() { fn jsonc() {
let rc = parse_swcrc(include_str!("jsonc.json")).expect("failed to parse"); let rc = parse_swcrc(include_str!("jsonc.json")).expect("failed to parse");

View File

@ -40,14 +40,6 @@ fn swcrc_simple() {
println!("{}", f); println!("{}", f);
} }
#[test]
fn issue_1532() {
let f = file("tests/swcrc_errors/issue-1532/index.js");
println!("{}", f);
assert!(f.contains("unknown variant `esnext`"))
}
#[testing::fixture("tests/errors/**/input.js")] #[testing::fixture("tests/errors/**/input.js")]
#[testing::fixture("tests/errors/**/input.ts")] #[testing::fixture("tests/errors/**/input.ts")]
fn fixture(input: PathBuf) { fn fixture(input: PathBuf) {

View File

@ -126,6 +126,8 @@ pub enum EsVersion {
Es2021, Es2021,
#[serde(rename = "es2022")] #[serde(rename = "es2022")]
Es2022, Es2022,
#[serde(rename = "esnext")]
EsNext,
} }
impl EsVersion { impl EsVersion {

View File

@ -10,34 +10,6 @@ it("should work", () => {
}).toThrow("jsc"); }).toThrow("jsc");
}); });
it("should work", () => {
expect(() => {
const filename = 'index.ts';
const code = `
export async function getDependency(): Promise<any> {
return import('./dep').then(({dependency}) => dependency);
}
`
const options = {
jsc: {
parser: {
syntax: 'typescript',
dynamicImport: true
},
externalHelpers: true,
target: 'esnext'
},
sourceMaps: true,
filename
}
swc.transformSync(code, options)
}).toThrow("unknown variant `esnext`");
});
it("should report good error", () => { it("should report good error", () => {
expect(() => { expect(() => {
swc.transformFileSync(__dirname + "/../tests/error/simple.js"); swc.transformFileSync(__dirname + "/../tests/error/simple.js");