feat(transformer_conformance): enable typescript when the typescript plugin is present (#3007)

This commit is contained in:
Dunqing 2024-04-16 18:47:06 +08:00 committed by GitHub
parent 99e038cfc0
commit cdd3bc5a4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View file

@ -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

View file

@ -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);