From cdd3bc5a4e7ef39ab4bd1ba5797deb69e97f9442 Mon Sep 17 00:00:00 2001 From: Dunqing Date: Tue, 16 Apr 2024 18:47:06 +0800 Subject: [PATCH] feat(transformer_conformance): enable typescript when the typescript plugin is present (#3007) --- tasks/transform_conformance/babel.snap.md | 6 ++---- tasks/transform_conformance/src/test_case.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tasks/transform_conformance/babel.snap.md b/tasks/transform_conformance/babel.snap.md index 532f9d6dc..32e6cafa0 100644 --- a/tasks/transform_conformance/babel.snap.md +++ b/tasks/transform_conformance/babel.snap.md @@ -1,4 +1,4 @@ -Passed: 136/217 +Passed: 138/217 # All Passed: * babel-plugin-transform-react-jsx-source @@ -16,7 +16,7 @@ Passed: 136/217 * opts/optimizeConstEnums/input.ts * opts/rewriteImportExtensions/input.ts -# babel-plugin-transform-typescript (82/147) +# babel-plugin-transform-typescript (84/147) * class/abstract-allowDeclareFields-false/input.ts * class/abstract-allowDeclareFields-true/input.ts * class/abstract-class-decorated/input.ts @@ -31,12 +31,10 @@ Passed: 136/217 * class/parameter-properties-with-super/input.ts * class/private-method-override-transform-private/input.ts * class/transform-properties-declare-wrong-order/input.ts -* declarations/nested-namespace/input.mjs * exports/declared-types/input.ts * exports/export-const-enums/input.ts * exports/export-type-star-from/input.ts * exports/export=/input.ts -* function/overloads-exports/input.mjs * imports/enum-id/input.ts * imports/enum-value/input.ts * imports/import=-module/input.ts diff --git a/tasks/transform_conformance/src/test_case.rs b/tasks/transform_conformance/src/test_case.rs index cecacae8b..abaf0664f 100644 --- a/tasks/transform_conformance/src/test_case.rs +++ b/tasks/transform_conformance/src/test_case.rs @@ -188,7 +188,11 @@ pub trait TestCase { let allocator = Allocator::default(); let source_text = fs::read_to_string(path).unwrap(); - let source_type = SourceType::from_path(path).unwrap().with_typescript(false); + let source_type = SourceType::from_path(path).unwrap().with_typescript( + // Some babel test cases have a js extension, but contain typescript code. + // Therefore, if the typescript plugin exists, enable the typescript. + self.options().get_plugin("transform-typescript").is_some(), + ); let ret = Parser::new(&allocator, &source_text, source_type).parse(); @@ -260,7 +264,7 @@ impl TestCase for ConformanceTestCase { } else { input_is_js && output_is_js }) - .with_typescript(false); + .with_typescript(self.options.get_plugin("transform-typescript").is_some()); if filtered { println!("input_path: {:?}", &self.path);