Skip to content

Commit 354ae1a

Browse files
committed
Remove isImplicitThis
1 parent 9a16ccf commit 354ae1a

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
coverage/
2-
dist/
2+
dist*/
33
node_modules/
44
*.log
55
.yarn/*

src/transform-node.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,13 @@ function isOptionalObjectOrCallee(node: NGNode): boolean {
2727
);
2828
}
2929

30-
function isImplicitThis(node: angular.AST, text: string): boolean {
31-
const { start, end } = node.sourceSpan;
32-
return start >= end || /^\s+$/.test(text.slice(start, end));
33-
}
34-
3530
type NodeTransformOptions = {
3631
ancestors: angular.AST[];
3732
};
3833

3934
class Transformer extends Source {
40-
#text;
41-
4235
constructor(text: string) {
4336
super(text);
44-
this.#text = text;
4537
}
4638

4739
transform<T extends NGNode>(
@@ -457,24 +449,27 @@ class Transformer extends Source {
457449

458450
const { receiver } = node;
459451

460-
const implicit = isImplicitThis(receiver, this.#text);
452+
let isImplicitThis;
461453

462454
let property;
463455
if (isComputed) {
456+
isImplicitThis = node.sourceSpan.start === node.key.sourceSpan.start;
464457
property = this.transform<babel.Expression>(node.key);
465458
} else {
466-
const { name } = node;
459+
const { name, nameSpan } = node;
460+
461+
isImplicitThis = node.sourceSpan.start === nameSpan.start;
467462
property = this.#create<babel.Identifier>(
468463
{
469464
type: 'Identifier',
470465
name,
471466
...node.nameSpan,
472467
},
473-
implicit ? ancestors : [],
468+
isImplicitThis ? ancestors : [],
474469
);
475470
}
476471

477-
if (implicit || receiver.sourceSpan.start === property.start) {
472+
if (isImplicitThis) {
478473
return property;
479474
}
480475

0 commit comments

Comments
 (0)