Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions crates/oxc_transformer/src/es2015/arrow_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,10 @@ impl<'a> ArrowFunctions<'a> {
// ```
//
// `this` resolves to the class / class instance (i.e. `this` defined *within* the class) in:
// * Class method bodies
// * Class property bodies
// * Class static blocks
// * Method body
// * Method param
// * Property value
// * Static block
//
// ```js
// // All these `this` refer to `this` defined within the class
Expand All @@ -281,6 +282,7 @@ impl<'a> ArrowFunctions<'a> {
// d() { this }
// static e() { this }
// #f() { this }
// g(x = this) {}
// static { this }
// }
// ```
Expand All @@ -291,24 +293,15 @@ impl<'a> ArrowFunctions<'a> {
// Top level
Ancestor::ProgramBody(_)
// Function (includes class method body)
| Ancestor::FunctionTypeParameters(_)
| Ancestor::FunctionThisParam(_)
| Ancestor::FunctionParams(_)
| Ancestor::FunctionReturnType(_)
| Ancestor::FunctionBody(_)
// Class property body
| Ancestor::PropertyDefinitionValue(_)
// Class static block
| Ancestor::StaticBlockBody(_) => return None,
Ancestor::ArrowFunctionExpressionTypeParameters(func) => {
return Some(func.scope_id().get().unwrap())
}
Ancestor::ArrowFunctionExpressionParams(func) => {
return Some(func.scope_id().get().unwrap())
}
Ancestor::ArrowFunctionExpressionReturnType(func) => {
return Some(func.scope_id().get().unwrap())
}
Ancestor::ArrowFunctionExpressionBody(func) => {
return Some(func.scope_id().get().unwrap())
}
Expand Down