@@ -3,7 +3,7 @@ import * as AST from './ast';
33import { createIdentifierDecorator } from './decorator-helper' ;
44import type { DecoratorImportInfoMap } from './decorator-info' ;
55import type { EOClassDecorator , EOProp } from './eo-prop/index' ;
6- import makeEOProp from './eo-prop/index' ;
6+ import makeEOProp , { isEOClassDecorator , isEOProp } from './eo-prop/index' ;
77import logger from './log-helper' ;
88import type { Options } from './options' ;
99import { getClassName , getExpressionToReplace } from './parse-helper' ;
@@ -16,8 +16,7 @@ export default class EOExtendExpression {
1616
1717 private expression : AST . EOExpression | null = null ;
1818 private mixins : AST . EOMixin [ ] ;
19- readonly properties : EOProp [ ] ;
20- readonly decorators : EOClassDecorator [ ] ;
19+ readonly properties : Array < EOClassDecorator | EOProp > ;
2120
2221 constructor (
2322 private path : AST . Path < AST . EOExtendExpression > ,
@@ -48,24 +47,9 @@ export default class EOExtendExpression {
4847 this . mixins = mixins ;
4948
5049 const rawProperties = this . expression ?. properties ?? [ ] ;
51- const properties : EOProp [ ] = [ ] ;
52- const decorators : EOClassDecorator [ ] = [ ] ;
53-
54- for ( const property of rawProperties ) {
55- const eoProp = makeEOProp (
56- property ,
57- existingDecoratorImportInfos ,
58- options
59- ) ;
60- if ( eoProp . isClassDecorator ) {
61- decorators . push ( eoProp ) ;
62- } else {
63- properties . push ( eoProp ) ;
64- }
65- }
66-
67- this . properties = properties ;
68- this . decorators = decorators ;
50+ this . properties = rawProperties . map ( ( raw ) =>
51+ makeEOProp ( raw , existingDecoratorImportInfos , options )
52+ ) ;
6953 }
7054
7155 transform ( ) : boolean {
@@ -97,8 +81,8 @@ export default class EOExtendExpression {
9781 tagName : false ,
9882 unobserves : false ,
9983 } ;
100- const allProps = [ ... this . decorators , ... this . properties ] ;
101- for ( const prop of allProps ) {
84+ const { properties } = this ;
85+ for ( const prop of properties ) {
10286 specs = {
10387 action : specs . action || prop . decoratorImportSpecs . action ,
10488 classNames : specs . classNames || prop . decoratorImportSpecs . classNames ,
@@ -151,10 +135,10 @@ export default class EOExtendExpression {
151135 }
152136
153137 private buildClassBody ( ) : AST . ClassBody {
154- const { properties } = this ;
138+ const objectProperties = this . properties . filter ( isEOProp ) ;
155139 let classBody : Parameters < AST . ClassBodyBuilder > [ 0 ] = [ ] ;
156140
157- for ( const prop of properties ) {
141+ for ( const prop of objectProperties ) {
158142 const built = prop . build ( ) ;
159143 if ( Array . isArray ( built ) ) {
160144 classBody = [ ...classBody , ...built ] ;
@@ -186,16 +170,16 @@ export default class EOExtendExpression {
186170 }
187171
188172 private buildClassDecorators ( ) : AST . Decorator [ ] {
189- const { decorators } = this ;
173+ const classDecoratorProperties = this . properties . filter ( isEOClassDecorator ) ;
190174 const { classicDecorator } = this . options ;
191175 const classDecorators : AST . Decorator [ ] = [ ] ;
192176
193177 if ( classicDecorator ) {
194178 classDecorators . push ( createIdentifierDecorator ( 'classic' ) ) ;
195179 }
196180
197- for ( const decorator of decorators ) {
198- classDecorators . push ( decorator . build ( ) ) ;
181+ for ( const prop of classDecoratorProperties ) {
182+ classDecorators . push ( prop . build ( ) ) ;
199183 }
200184
201185 return classDecorators ;
@@ -219,6 +203,7 @@ export default class EOExtendExpression {
219203 for ( const prop of this . properties ) {
220204 errors = [ ...errors , ...prop . errors ] ;
221205 }
206+
222207 return errors ;
223208 }
224209
0 commit comments