mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(transformer/typescript): remove more typescript ast nodes (#3563)
Remove more TypeScript related AST
This commit is contained in:
parent
5c8e16c976
commit
a939ddd096
6 changed files with 44 additions and 44 deletions
|
|
@ -1136,6 +1136,9 @@ impl<'a> AssignmentTarget<'a> {
|
|||
pub fn get_identifier(&self) -> Option<&str> {
|
||||
self.as_simple_assignment_target().and_then(|it| it.get_identifier())
|
||||
}
|
||||
pub fn get_expression(&self) -> Option<&Expression<'a>> {
|
||||
self.as_simple_assignment_target().and_then(|it| it.get_expression())
|
||||
}
|
||||
}
|
||||
|
||||
/// Macro for matching `AssignmentTarget`'s variants.
|
||||
|
|
|
|||
|
|
@ -165,6 +165,14 @@ impl<'a> Traverse<'a> for Transformer<'a> {
|
|||
self.x0_typescript.transform_simple_assignment_target(node);
|
||||
}
|
||||
|
||||
fn enter_assignment_target(
|
||||
&mut self,
|
||||
node: &mut AssignmentTarget<'a>,
|
||||
_ctx: &mut TraverseCtx<'a>,
|
||||
) {
|
||||
self.x0_typescript.transform_assignment_target(node);
|
||||
}
|
||||
|
||||
fn enter_formal_parameter(
|
||||
&mut self,
|
||||
param: &mut FormalParameter<'a>,
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ impl<'a> TypeScriptAnnotations<'a> {
|
|||
.as_ref()
|
||||
.is_some_and(|specifiers| specifiers.is_empty()))
|
||||
}
|
||||
_ => false,
|
||||
_ => module_decl.is_typescript_syntax(),
|
||||
};
|
||||
|
||||
if need_delete {
|
||||
|
|
@ -265,6 +265,23 @@ impl<'a> TypeScriptAnnotations<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn transform_assignment_target(&mut self, target: &mut AssignmentTarget<'a>) {
|
||||
if let Some(new_target) = target
|
||||
.get_expression()
|
||||
.map(Expression::get_inner_expression)
|
||||
.and_then(|expr| match expr {
|
||||
match_member_expression!(Expression) => {
|
||||
Some(self.ctx.ast.simple_assignment_target_member_expression(
|
||||
self.ctx.ast.copy(expr.as_member_expression().unwrap()),
|
||||
))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
{
|
||||
*target = new_target;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn transform_formal_parameter(&mut self, param: &mut FormalParameter<'a>) {
|
||||
param.accessibility = None;
|
||||
}
|
||||
|
|
@ -283,15 +300,17 @@ impl<'a> TypeScriptAnnotations<'a> {
|
|||
// Collects parameter properties so that we can add an assignment
|
||||
// for each of them in the constructor body.
|
||||
if def.kind == MethodDefinitionKind::Constructor {
|
||||
for param in &def.value.params.items {
|
||||
if !param.is_public() {
|
||||
continue;
|
||||
for param in def.value.params.items.as_mut_slice() {
|
||||
if param.is_public() {
|
||||
if let Some(id) = param.pattern.get_identifier() {
|
||||
let assignment = self.create_this_property_assignment(id);
|
||||
self.assignments.push(assignment);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(id) = param.pattern.get_identifier() {
|
||||
let assignment = self.create_this_property_assignment(id);
|
||||
self.assignments.push(assignment);
|
||||
}
|
||||
param.readonly = false;
|
||||
param.accessibility = None;
|
||||
param.r#override = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,6 +113,10 @@ impl<'a> TypeScript<'a> {
|
|||
self.annotations.transform_simple_assignment_target(target);
|
||||
}
|
||||
|
||||
pub fn transform_assignment_target(&mut self, target: &mut AssignmentTarget<'a>) {
|
||||
self.annotations.transform_assignment_target(target);
|
||||
}
|
||||
|
||||
pub fn transform_formal_parameter(&mut self, param: &mut FormalParameter<'a>) {
|
||||
self.annotations.transform_formal_parameter(param);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,4 @@ commit: 4bd1b2c2
|
|||
|
||||
transformer_babel Summary:
|
||||
AST Parsed : 2099/2099 (100.00%)
|
||||
Positive Passed: 2097/2099 (99.90%)
|
||||
Mismatch: "typescript/class/parameter-properties/input.ts"
|
||||
Mismatch: "typescript/export/as-namespace/input.ts"
|
||||
Positive Passed: 2099/2099 (100.00%)
|
||||
|
|
|
|||
|
|
@ -2,37 +2,5 @@ commit: 64d2eeea
|
|||
|
||||
transformer_typescript Summary:
|
||||
AST Parsed : 5243/5243 (100.00%)
|
||||
Positive Passed: 5210/5243 (99.37%)
|
||||
Mismatch: "compiler/amdModuleName1.ts"
|
||||
Mismatch: "compiler/avoidCycleWithVoidExpressionReturnedFromArrow.ts"
|
||||
Mismatch: "compiler/clinterfaces.ts"
|
||||
Mismatch: "compiler/collectionPatternNoError.ts"
|
||||
Mismatch: "compiler/comparabilityTypeParametersRelatedByUnion.ts"
|
||||
Mismatch: "compiler/constEnumMergingWithValues1.ts"
|
||||
Mismatch: "compiler/constEnumMergingWithValues2.ts"
|
||||
Mismatch: "compiler/constEnumMergingWithValues3.ts"
|
||||
Mismatch: "compiler/constEnumMergingWithValues4.ts"
|
||||
Mismatch: "compiler/constEnumMergingWithValues5.ts"
|
||||
Positive Passed: 5242/5243 (99.98%)
|
||||
Mismatch: "compiler/elidedEmbeddedStatementsReplacedWithSemicolon.ts"
|
||||
Mismatch: "compiler/es5-umd4.ts"
|
||||
Mismatch: "compiler/exportAssignValueAndType.ts"
|
||||
Mismatch: "compiler/exportAssignmentWithPrivacyError.ts"
|
||||
Mismatch: "compiler/exportAssignmentWithoutIdentifier1.ts"
|
||||
Mismatch: "compiler/exportEqualNamespaces.ts"
|
||||
Mismatch: "compiler/exportEqualsAmd.ts"
|
||||
Mismatch: "compiler/exportEqualsClassNoRedeclarationError.ts"
|
||||
Mismatch: "compiler/exportEqualsCommonJs.ts"
|
||||
Mismatch: "compiler/exportEqualsUmd.ts"
|
||||
Mismatch: "compiler/module_augmentUninstantiatedModule2.ts"
|
||||
Mismatch: "compiler/noCircularDefinitionOnExportOfPrivateInMergedNamespace.ts"
|
||||
Mismatch: "compiler/noErrorUsingImportExportModuleAugmentationInDeclarationFile1.ts"
|
||||
Mismatch: "compiler/recursiveFieldSetting.ts"
|
||||
Mismatch: "compiler/sourceMapValidationExportAssignment.ts"
|
||||
Mismatch: "compiler/sourceMapValidationExportAssignmentCommonjs.ts"
|
||||
Mismatch: "compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts"
|
||||
Mismatch: "compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts"
|
||||
Mismatch: "conformance/classes/members/privateNames/privateNameFieldParenthesisLeftAssignment.ts"
|
||||
Mismatch: "conformance/classes/propertyMemberDeclarations/initializationOrdering1.ts"
|
||||
Mismatch: "conformance/classes/propertyMemberDeclarations/instanceMemberInitialization.ts"
|
||||
Mismatch: "conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter5.ts"
|
||||
Mismatch: "conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.2.ts"
|
||||
|
|
|
|||
Loading…
Reference in a new issue