@@ -358,10 +358,6 @@ export function addSymbolToNgModuleMetadata(
358
358
metadataField ,
359
359
) ;
360
360
361
- // Get the last node of the array literal.
362
- if ( ! matchingProperties ) {
363
- return [ ] ;
364
- }
365
361
if ( matchingProperties . length == 0 ) {
366
362
// We haven't found the field in the metadata declaration. Insert a new field.
367
363
const expr = node as ts . ObjectLiteralExpression ;
@@ -406,13 +402,6 @@ export function addSymbolToNgModuleMetadata(
406
402
node = arrLiteral . elements ;
407
403
}
408
404
409
- if ( ! node ) {
410
- // tslint:disable-next-line: no-console
411
- console . error ( 'No app module found. Please add your new class to your component.' ) ;
412
-
413
- return [ ] ;
414
- }
415
-
416
405
if ( Array . isArray ( node ) ) {
417
406
const nodeArray = node as { } as Array < ts . Node > ;
418
407
const symbolsArray = nodeArray . map ( node => node . getText ( ) ) ;
@@ -425,23 +414,7 @@ export function addSymbolToNgModuleMetadata(
425
414
426
415
let toInsert : string ;
427
416
let position = node . getEnd ( ) ;
428
- if ( node . kind == ts . SyntaxKind . ObjectLiteralExpression ) {
429
- // We haven't found the field in the metadata declaration. Insert a new
430
- // field.
431
- const expr = node as ts . ObjectLiteralExpression ;
432
- if ( expr . properties . length == 0 ) {
433
- position = expr . getEnd ( ) - 1 ;
434
- toInsert = ` ${ symbolName } \n` ;
435
- } else {
436
- // Get the indentation of the last element, if any.
437
- const text = node . getFullText ( source ) ;
438
- if ( text . match ( / ^ \r ? \r ? \n / ) ) {
439
- toInsert = `,${ text . match ( / ^ \r ? \n \s * / ) [ 0 ] } ${ symbolName } ` ;
440
- } else {
441
- toInsert = `, ${ symbolName } ` ;
442
- }
443
- }
444
- } else if ( node . kind == ts . SyntaxKind . ArrayLiteralExpression ) {
417
+ if ( node . kind == ts . SyntaxKind . ArrayLiteralExpression ) {
445
418
// We found the field but it's empty. Insert it just before the `]`.
446
419
position -- ;
447
420
toInsert = `${ symbolName } ` ;
0 commit comments