@@ -1850,8 +1850,7 @@ describe('animation tests', function() {
1850
1850
]
1851
1851
} )
1852
1852
class Cmp {
1853
- // TODO(issue/24571): remove '!'.
1854
- public exp ! : string | null ;
1853
+ public exp : string | null | undefined ;
1855
1854
}
1856
1855
1857
1856
TestBed . configureTestingModule ( { declarations : [ Cmp ] } ) ;
@@ -2236,8 +2235,7 @@ describe('animation tests', function() {
2236
2235
} )
2237
2236
class Cmp {
2238
2237
public exp : any ;
2239
- // TODO(issue/24571): remove '!'.
2240
- public color ! : string | null ;
2238
+ public color : string | null | undefined ;
2241
2239
}
2242
2240
2243
2241
TestBed . configureTestingModule ( { declarations : [ Cmp ] } ) ;
@@ -2737,8 +2735,7 @@ describe('animation tests', function() {
2737
2735
} )
2738
2736
class Cmp {
2739
2737
exp : any = false ;
2740
- // TODO(issue/24571): remove '!'.
2741
- event ! : AnimationEvent ;
2738
+ event : AnimationEvent | undefined ;
2742
2739
2743
2740
callback = ( event : any ) => {
2744
2741
this . event = event ;
@@ -2754,11 +2751,11 @@ describe('animation tests', function() {
2754
2751
fixture . detectChanges ( ) ;
2755
2752
flushMicrotasks ( ) ;
2756
2753
2757
- expect ( cmp . event . triggerName ) . toEqual ( 'myAnimation' ) ;
2758
- expect ( cmp . event . phaseName ) . toEqual ( 'start' ) ;
2759
- expect ( cmp . event . totalTime ) . toEqual ( 500 ) ;
2760
- expect ( cmp . event . fromState ) . toEqual ( 'void' ) ;
2761
- expect ( cmp . event . toState ) . toEqual ( 'true' ) ;
2754
+ expect ( cmp . event ? .triggerName ) . toEqual ( 'myAnimation' ) ;
2755
+ expect ( cmp . event ? .phaseName ) . toEqual ( 'start' ) ;
2756
+ expect ( cmp . event ? .totalTime ) . toEqual ( 500 ) ;
2757
+ expect ( cmp . event ? .fromState ) . toEqual ( 'void' ) ;
2758
+ expect ( cmp . event ? .toState ) . toEqual ( 'true' ) ;
2762
2759
} ) ) ;
2763
2760
2764
2761
it ( 'should trigger a `done` state change listener for when the animation changes state from a => b' ,
@@ -2775,8 +2772,7 @@ describe('animation tests', function() {
2775
2772
} )
2776
2773
class Cmp {
2777
2774
exp : any = false ;
2778
- // TODO(issue/24571): remove '!'.
2779
- event ! : AnimationEvent ;
2775
+ event : AnimationEvent | undefined ;
2780
2776
2781
2777
callback = ( event : any ) => {
2782
2778
this . event = event ;
@@ -2799,11 +2795,11 @@ describe('animation tests', function() {
2799
2795
player . finish ( ) ;
2800
2796
flushMicrotasks ( ) ;
2801
2797
2802
- expect ( cmp . event . triggerName ) . toEqual ( 'myAnimation123' ) ;
2803
- expect ( cmp . event . phaseName ) . toEqual ( 'done' ) ;
2804
- expect ( cmp . event . totalTime ) . toEqual ( 999 ) ;
2805
- expect ( cmp . event . fromState ) . toEqual ( 'void' ) ;
2806
- expect ( cmp . event . toState ) . toEqual ( 'b' ) ;
2798
+ expect ( cmp . event ? .triggerName ) . toEqual ( 'myAnimation123' ) ;
2799
+ expect ( cmp . event ? .phaseName ) . toEqual ( 'done' ) ;
2800
+ expect ( cmp . event ? .totalTime ) . toEqual ( 999 ) ;
2801
+ expect ( cmp . event ? .fromState ) . toEqual ( 'void' ) ;
2802
+ expect ( cmp . event ? .toState ) . toEqual ( 'b' ) ;
2807
2803
} ) ) ;
2808
2804
2809
2805
it ( 'should handle callbacks for multiple triggers running simultaneously' , fakeAsync ( ( ) => {
@@ -2832,10 +2828,8 @@ describe('animation tests', function() {
2832
2828
class Cmp {
2833
2829
exp1 : any = false ;
2834
2830
exp2 : any = false ;
2835
- // TODO(issue/24571): remove '!'.
2836
- event1 ! : AnimationEvent ;
2837
- // TODO(issue/24571): remove '!'.
2838
- event2 ! : AnimationEvent ;
2831
+ event1 : AnimationEvent | undefined ;
2832
+ event2 : AnimationEvent | undefined ;
2839
2833
// tslint:disable:semicolon
2840
2834
callback1 = ( event : any ) => {
2841
2835
this . event1 = event ;
@@ -2869,8 +2863,8 @@ describe('animation tests', function() {
2869
2863
expect ( cmp . event2 ) . toBeFalsy ( ) ;
2870
2864
2871
2865
flushMicrotasks ( ) ;
2872
- expect ( cmp . event1 . triggerName ) . toBeTruthy ( 'ani1' ) ;
2873
- expect ( cmp . event2 . triggerName ) . toBeTruthy ( 'ani2' ) ;
2866
+ expect ( cmp . event1 ? .triggerName ) . toBeTruthy ( 'ani1' ) ;
2867
+ expect ( cmp . event2 ? .triggerName ) . toBeTruthy ( 'ani2' ) ;
2874
2868
} ) ) ;
2875
2869
2876
2870
it ( 'should handle callbacks for multiple triggers running simultaneously on the same element' ,
@@ -2899,10 +2893,8 @@ describe('animation tests', function() {
2899
2893
class Cmp {
2900
2894
exp1 : any = false ;
2901
2895
exp2 : any = false ;
2902
- // TODO(issue/24571): remove '!'.
2903
- event1 ! : AnimationEvent ;
2904
- // TODO(issue/24571): remove '!'.
2905
- event2 ! : AnimationEvent ;
2896
+ event1 : AnimationEvent | undefined ;
2897
+ event2 : AnimationEvent | undefined ;
2906
2898
callback1 = ( event : any ) => {
2907
2899
this . event1 = event ;
2908
2900
} ;
@@ -2934,8 +2926,8 @@ describe('animation tests', function() {
2934
2926
expect ( cmp . event2 ) . toBeFalsy ( ) ;
2935
2927
2936
2928
flushMicrotasks ( ) ;
2937
- expect ( cmp . event1 . triggerName ) . toBeTruthy ( 'ani1' ) ;
2938
- expect ( cmp . event2 . triggerName ) . toBeTruthy ( 'ani2' ) ;
2929
+ expect ( cmp . event1 ? .triggerName ) . toBeTruthy ( 'ani1' ) ;
2930
+ expect ( cmp . event2 ? .triggerName ) . toBeTruthy ( 'ani2' ) ;
2939
2931
} ) ) ;
2940
2932
2941
2933
it ( 'should handle a leave animation for multiple triggers even if not all triggers have their own leave transition specified' ,
@@ -3010,8 +3002,7 @@ describe('animation tests', function() {
3010
3002
[ style ( { 'opacity' : '0' } ) , animate ( 1000 , style ( { 'opacity' : '1' } ) ) ] ) ] ) ] ,
3011
3003
} )
3012
3004
class Cmp {
3013
- // TODO(issue/24571): remove '!'.
3014
- event ! : AnimationEvent ;
3005
+ event : AnimationEvent | undefined ;
3015
3006
3016
3007
@HostBinding ( '@myAnimation2' ) exp : any = false ;
3017
3008
@@ -3030,11 +3021,11 @@ describe('animation tests', function() {
3030
3021
fixture . detectChanges ( ) ;
3031
3022
flushMicrotasks ( ) ;
3032
3023
3033
- expect ( cmp . event . triggerName ) . toEqual ( 'myAnimation2' ) ;
3034
- expect ( cmp . event . phaseName ) . toEqual ( 'start' ) ;
3035
- expect ( cmp . event . totalTime ) . toEqual ( 1000 ) ;
3036
- expect ( cmp . event . fromState ) . toEqual ( 'void' ) ;
3037
- expect ( cmp . event . toState ) . toEqual ( 'TRUE' ) ;
3024
+ expect ( cmp . event ? .triggerName ) . toEqual ( 'myAnimation2' ) ;
3025
+ expect ( cmp . event ? .phaseName ) . toEqual ( 'start' ) ;
3026
+ expect ( cmp . event ? .totalTime ) . toEqual ( 1000 ) ;
3027
+ expect ( cmp . event ? .fromState ) . toEqual ( 'void' ) ;
3028
+ expect ( cmp . event ? .toState ) . toEqual ( 'TRUE' ) ;
3038
3029
} ) ) ;
3039
3030
3040
3031
it ( 'should always fire callbacks even when a transition is not detected' , fakeAsync ( ( ) => {
@@ -3046,8 +3037,7 @@ describe('animation tests', function() {
3046
3037
animations : [ trigger ( 'myAnimation' , [ ] ) ]
3047
3038
} )
3048
3039
class Cmp {
3049
- // TODO(issue/24571): remove '!'.
3050
- exp ! : string ;
3040
+ exp : string | undefined ;
3051
3041
log : any [ ] = [ ] ;
3052
3042
callback = ( event : any ) => this . log . push ( `${ event . phaseName } => ${ event . toState } ` ) ;
3053
3043
}
@@ -3158,10 +3148,8 @@ describe('animation tests', function() {
3158
3148
} )
3159
3149
class Cmp {
3160
3150
log : string [ ] = [ ] ;
3161
- // TODO(issue/24571): remove '!'.
3162
- exp1 ! : string ;
3163
- // TODO(issue/24571): remove '!'.
3164
- exp2 ! : string ;
3151
+ exp1 : string | undefined ;
3152
+ exp2 : string | undefined ;
3165
3153
3166
3154
cb ( name : string , event : AnimationEvent ) {
3167
3155
this . log . push ( name ) ;
@@ -3239,8 +3227,7 @@ describe('animation tests', function() {
3239
3227
class Cmp {
3240
3228
log : string [ ] = [ ] ;
3241
3229
events : { [ name : string ] : any } = { } ;
3242
- // TODO(issue/24571): remove '!'.
3243
- exp ! : string ;
3230
+ exp : string | undefined ;
3244
3231
items : any = [ 0 , 1 , 2 , 3 ] ;
3245
3232
3246
3233
cb ( name : string , phase : string , event : AnimationEvent ) {
@@ -3546,7 +3533,7 @@ describe('animation tests', function() {
3546
3533
fixture . detectChanges ( ) ;
3547
3534
resetLog ( ) ;
3548
3535
3549
- const parent = cmp . parentElm ! . nativeElement ;
3536
+ const parent = cmp . parentElm . nativeElement ;
3550
3537
3551
3538
cmp . exp = true ;
3552
3539
fixture . detectChanges ( ) ;
@@ -3580,10 +3567,8 @@ describe('animation tests', function() {
3580
3567
class Cmp {
3581
3568
disableExp = false ;
3582
3569
exp = '' ;
3583
- // TODO(issue/24571): remove '!'.
3584
- startEvent ! : AnimationEvent ;
3585
- // TODO(issue/24571): remove '!'.
3586
- doneEvent ! : AnimationEvent ;
3570
+ startEvent : AnimationEvent | undefined ;
3571
+ doneEvent : AnimationEvent | undefined ;
3587
3572
}
3588
3573
3589
3574
TestBed . configureTestingModule ( { declarations : [ Cmp ] } ) ;
@@ -3599,17 +3584,17 @@ describe('animation tests', function() {
3599
3584
cmp . exp = '1' ;
3600
3585
fixture . detectChanges ( ) ;
3601
3586
flushMicrotasks ( ) ;
3602
- expect ( cmp . startEvent . totalTime ) . toEqual ( 9876 ) ;
3603
- expect ( cmp . startEvent . disabled ) . toBeTruthy ( ) ;
3604
- expect ( cmp . doneEvent . totalTime ) . toEqual ( 9876 ) ;
3605
- expect ( cmp . doneEvent . disabled ) . toBeTruthy ( ) ;
3587
+ expect ( cmp . startEvent ? .totalTime ) . toEqual ( 9876 ) ;
3588
+ expect ( cmp . startEvent ? .disabled ) . toBeTruthy ( ) ;
3589
+ expect ( cmp . doneEvent ? .totalTime ) . toEqual ( 9876 ) ;
3590
+ expect ( cmp . doneEvent ? .disabled ) . toBeTruthy ( ) ;
3606
3591
3607
3592
cmp . exp = '2' ;
3608
3593
cmp . disableExp = false ;
3609
3594
fixture . detectChanges ( ) ;
3610
3595
flushMicrotasks ( ) ;
3611
- expect ( cmp . startEvent . totalTime ) . toEqual ( 9876 ) ;
3612
- expect ( cmp . startEvent . disabled ) . toBeFalsy ( ) ;
3596
+ expect ( cmp . startEvent ? .totalTime ) . toEqual ( 9876 ) ;
3597
+ expect ( cmp . startEvent ? .disabled ) . toBeFalsy ( ) ;
3613
3598
// the done event isn't fired because it's an actual animation
3614
3599
} ) ) ;
3615
3600
0 commit comments