swc_ecma_transforms:

- remove this parameter from typescript::strip pass (fixes #236)
This commit is contained in:
강동윤 2019-02-19 14:30:26 +09:00
parent 4dc10d849e
commit 4fddea0bbd
2 changed files with 23 additions and 0 deletions

View File

@ -162,6 +162,23 @@ impl Fold<Constructor> for Strip {
}
}
impl Fold<Vec<Pat>> for Strip {
fn fold(&mut self, pats: Vec<Pat>) -> Vec<Pat> {
let mut pats = pats.fold_children(self);
// Remove this from parameter list
pats.retain(|pat| match *pat {
Pat::Ident(Ident {
sym: js_word!("this"),
..
}) => false,
_ => true,
});
pats
}
}
impl Fold<Vec<ModuleItem>> for Strip {
fn fold(&mut self, items: Vec<ModuleItem>) -> Vec<ModuleItem> {
// First pass

View File

@ -82,3 +82,9 @@ const a: Types = Types.foo;",
"import {Types} from 'other';
const a = Types.foo;"
);
to!(
issue_236,
"function foo(this: any, $scope: angular.IScope){}",
"function foo($scope){}"
);