@@ -41,6 +41,15 @@ describe('@ngtools/webpack transformers', () => {
4141 'service.ts' : `
4242 export class Service { }
4343 ` ,
44+ 'type.ts' : `
45+ export interface OnChanges {
46+ ngOnChanges(changes: SimpleChanges): void;
47+ }
48+
49+ export interface SimpleChanges {
50+ [propName: string]: unknown;
51+ }
52+ ` ,
4453 } ;
4554
4655 it ( 'should remove unused imports' , ( ) => {
@@ -530,6 +539,40 @@ describe('@ngtools/webpack transformers', () => {
530539 expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
531540 } ) ;
532541
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+
533576 describe ( 'NGTSC - ShorthandPropertyAssignment to PropertyAssignment' , ( ) => {
534577 const transformShorthandPropertyAssignment = ( context : ts . TransformationContext ) : ts . Transformer < ts . SourceFile > => {
535578 const visit : ts . Visitor = node => {
0 commit comments