mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
feat(transformer): drop this parameter from typescript functions (#1019)
This commit is contained in:
parent
ee134f022c
commit
d31a667e23
3 changed files with 20 additions and 4 deletions
|
|
@ -144,4 +144,14 @@ impl<'a> VisitMut<'a> for Transformer<'a> {
|
|||
self.visit_class_element(class_element);
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_formal_parameters(&mut self, params: &mut FormalParameters<'a>) {
|
||||
self.typescript.as_mut().map(|t| t.transform_formal_parameters(params));
|
||||
for param in params.items.iter_mut() {
|
||||
self.visit_formal_parameter(param);
|
||||
}
|
||||
if let Some(rest) = &mut params.rest {
|
||||
self.visit_rest_element(rest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use oxc_ast::ast::*;
|
||||
use oxc_ast::AstBuilder;
|
||||
|
||||
use std::rc::Rc;
|
||||
|
|
@ -15,4 +16,11 @@ impl<'a> TypeScript<'a> {
|
|||
pub fn new(_ast: Rc<AstBuilder<'a>>) -> Self {
|
||||
Self { _ast }
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_self)]
|
||||
pub fn transform_formal_parameters(&self, params: &mut FormalParameters<'a>) {
|
||||
if params.items.get(0).is_some_and(|param| matches!(¶m.pattern.kind, BindingPatternKind::BindingIdentifier(ident) if ident.name =="this")) {
|
||||
params.items.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Passed: 160/1087
|
||||
Passed: 162/1087
|
||||
|
||||
# All Passed:
|
||||
* babel-plugin-transform-numeric-separator
|
||||
|
|
@ -714,7 +714,7 @@ Passed: 160/1087
|
|||
* unicode-regex/negated-set/input.js
|
||||
* unicode-regex/slash/input.js
|
||||
|
||||
# babel-plugin-transform-typescript (71/181)
|
||||
# babel-plugin-transform-typescript (73/181)
|
||||
* class/abstract-class-decorated/input.ts
|
||||
* class/abstract-class-decorated-method/input.ts
|
||||
* class/abstract-class-decorated-parameter/input.ts
|
||||
|
|
@ -749,7 +749,6 @@ Passed: 160/1087
|
|||
* enum/string-value-template/input.ts
|
||||
* enum/string-values-computed/input.ts
|
||||
* enum/ts5.0-const-foldable/input.ts
|
||||
* exports/declare-shadowed/input.ts
|
||||
* exports/declared-types/input.ts
|
||||
* exports/export-const-enums/input.ts
|
||||
* exports/export-type/input.ts
|
||||
|
|
@ -763,7 +762,6 @@ Passed: 160/1087
|
|||
* exports/type-only-export-specifier-2/input.ts
|
||||
* exports/type-only-export-specifier-3/input.ts
|
||||
* function/overloads-exports/input.mjs
|
||||
* function/this-parameter/input.ts
|
||||
* imports/elide-injected/input.ts
|
||||
* imports/elide-preact/input.ts
|
||||
* imports/elide-react/input.ts
|
||||
|
|
|
|||
Loading…
Reference in a new issue