@@ -41,6 +41,15 @@ describe('@ngtools/webpack transformers', () => {
41
41
'service.ts' : `
42
42
export class Service { }
43
43
` ,
44
+ 'type.ts' : `
45
+ export interface OnChanges {
46
+ ngOnChanges(changes: SimpleChanges): void;
47
+ }
48
+
49
+ export interface SimpleChanges {
50
+ [propName: string]: unknown;
51
+ }
52
+ ` ,
44
53
} ;
45
54
46
55
it ( 'should remove unused imports' , ( ) => {
@@ -530,6 +539,40 @@ describe('@ngtools/webpack transformers', () => {
530
539
expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
531
540
} ) ;
532
541
542
+ it ( 'should remove type-only imports' , ( ) => {
543
+ const input = tags . stripIndent `
544
+ import { Decorator } from './decorator';
545
+ import { Service } from './service';
546
+ import type { OnChanges, SimpleChanges } from './type';
547
+
548
+ @Decorator()
549
+ class Foo implements OnChanges {
550
+ constructor(param: Service) { }
551
+ ngOnChanges(changes: SimpleChanges) { }
552
+ }
553
+
554
+ ${ dummyNode }
555
+ ` ;
556
+
557
+ const output = tags . stripIndent `
558
+ import { __decorate, __metadata } from "tslib";
559
+ import { Decorator } from './decorator';
560
+ import { Service } from './service';
561
+
562
+ let Foo = class Foo {
563
+ constructor(param) { }
564
+ ngOnChanges(changes) { }
565
+ };
566
+
567
+ Foo = __decorate([ Decorator(), __metadata("design:paramtypes", [Service]) ], Foo);
568
+ ` ;
569
+
570
+ const { program, compilerHost } = createTypescriptContext ( input , additionalFiles , true , extraCompilerOptions ) ;
571
+ const result = transformTypescript ( undefined , [ transformer ( program ) ] , program , compilerHost ) ;
572
+
573
+ expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
574
+ } ) ;
575
+
533
576
describe ( 'NGTSC - ShorthandPropertyAssignment to PropertyAssignment' , ( ) => {
534
577
const transformShorthandPropertyAssignment = ( context : ts . TransformationContext ) : ts . Transformer < ts . SourceFile > => {
535
578
const visit : ts . Visitor = node => {
0 commit comments