mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(ast): Fix StaticMemberExpression.get_first_object (#6969)
I think `get_first_object` does not return expected expression.
For example, in case of `foo.bar.a`, it doesn't return `foo` but
`foo.bar`.
**Expected**
```
{
"type": "Identifier",
"start": 0,
"end": 3,
"name": "foo"
}
```
**Actual**
```
{
"type":"StaticMemberExpression",
"start":0,
"end":7,
"object":{
"type":"Identifier",
"start":0,
"end":3,
"name":"foo"
},
"property":{
"type":"Identifier",
"start":4,
"end":7,
"name":"bar"
},
"optional":false
}
```
---------
Co-authored-by: Dunqing <dengqing0821@gmail.com>
This commit is contained in:
parent
e23f7e6bc1
commit
0601271b2c
2 changed files with 1 additions and 25 deletions
|
|
@ -513,13 +513,7 @@ impl<'a> StaticMemberExpression<'a> {
|
|||
#[allow(missing_docs)]
|
||||
pub fn get_first_object(&self) -> &Expression<'a> {
|
||||
match &self.object {
|
||||
Expression::StaticMemberExpression(member) => {
|
||||
if let Expression::StaticMemberExpression(expr) = &member.object {
|
||||
expr.get_first_object()
|
||||
} else {
|
||||
&self.object
|
||||
}
|
||||
}
|
||||
Expression::StaticMemberExpression(member) => member.get_first_object(),
|
||||
Expression::ChainExpression(chain) => {
|
||||
if let ChainElement::StaticMemberExpression(expr) = &chain.expression {
|
||||
expr.get_first_object()
|
||||
|
|
|
|||
|
|
@ -114,15 +114,6 @@ export {};
|
|||
3 | }
|
||||
`----
|
||||
|
||||
x TS9014: Computed properties must be number or string literals, variables
|
||||
| or dotted expressions with --isolatedDeclarations.
|
||||
,-[declarationComputedPropertyNames.d.ts:12:6]
|
||||
11 | [Symbol.iterator]: number,
|
||||
12 | [globalThis.Symbol.toStringTag]: number,
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
13 | [(globalThis.Symbol).unscopables]: number,
|
||||
`----
|
||||
|
||||
x TS9014: Computed properties must be number or string literals, variables
|
||||
| or dotted expressions with --isolatedDeclarations.
|
||||
,-[declarationComputedPropertyNames.d.ts:13:6]
|
||||
|
|
@ -150,15 +141,6 @@ export {};
|
|||
19 | };
|
||||
`----
|
||||
|
||||
x TS9014: Computed properties must be number or string literals, variables
|
||||
| or dotted expressions with --isolatedDeclarations.
|
||||
,-[declarationComputedPropertyNames.d.ts:26:6]
|
||||
25 | [Symbol.iterator]: number,
|
||||
26 | [globalThis.Symbol.toStringTag]: number,
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
27 | [(globalThis.Symbol).unscopables]: number,
|
||||
`----
|
||||
|
||||
x TS9014: Computed properties must be number or string literals, variables
|
||||
| or dotted expressions with --isolatedDeclarations.
|
||||
,-[declarationComputedPropertyNames.d.ts:27:6]
|
||||
|
|
|
|||
Loading…
Reference in a new issue