Skip to content

Commit 64d7cd3

Browse files
committed
Allow logical expressions
1 parent 5999ac9 commit 64d7cd3

3 files changed

Lines changed: 37 additions & 13 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Program comments
3+
*/
4+
const Foo = Test.extend({
5+
location: ENV.locationType || 'history'
6+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import classic from 'ember-classic-decorator';
2+
3+
/**
4+
* Program comments
5+
*/
6+
@classic
7+
class Foo extends Test {
8+
location = ENV.locationType || 'history';
9+
}

transforms/helpers/ast.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import type { Type } from 'ast-types/lib/types';
44
import type {
55
ASTNode,
66
ArrayExpression,
7+
ArrayPattern,
8+
AssignmentPattern,
79
CallExpression,
810
FunctionExpression,
911
Identifier,
@@ -12,7 +14,13 @@ import type {
1214
MemberExpression,
1315
Node,
1416
ObjectExpression,
17+
ObjectPattern,
1518
Property,
19+
PropertyPattern,
20+
RestElement,
21+
SpreadElementPattern,
22+
SpreadPropertyPattern,
23+
TSParameterProperty,
1624
ThisExpression,
1725
ASTPath as _ASTPath,
1826
Collection as _Collection,
@@ -313,24 +321,25 @@ export function isEOIdentifierAction(u: unknown): u is EOIdentifierAction {
313321
}
314322

315323
export interface EOPropertySimple extends EOProperty {
316-
value:
317-
| ArrayExpression
318-
| Identifier
319-
| Literal
320-
| MemberExpression
321-
| ObjectExpression
322-
| CallExpression;
324+
value: Exclude<
325+
EOProperty['value'],
326+
| ArrayPattern
327+
| AssignmentPattern
328+
| ObjectPattern
329+
| PropertyPattern
330+
| RestElement
331+
| SpreadElementPattern
332+
| SpreadPropertyPattern
333+
| TSParameterProperty
334+
>;
323335
}
324336

325337
export function isEOPropertySimple(u: unknown): u is EOPropertySimple {
326338
return (
327339
isEOProperty(u) &&
328-
(isNode(u.value, 'ArrayExpression') ||
329-
isNode(u.value, 'Identifier') ||
330-
isNode(u.value, 'Literal') ||
331-
isNode(u.value, 'MemberExpression') ||
332-
isNode(u.value, 'ObjectExpression') ||
333-
isNode(u.value, 'CallExpression'))
340+
!u.value.type.includes('Pattern') &&
341+
u.value.type !== 'RestElement' &&
342+
u.value.type !== 'TSParameterProperty'
334343
);
335344
}
336345

0 commit comments

Comments
 (0)