@@ -333,7 +333,7 @@ class ElementDataSource extends DataSource<PeriodicElement> {
333333}
334334
335335// There's 1px of variance between different browsers in terms of positioning.
336- const approximateMatcher = {
336+ const approximateMatcher : jasmine . CustomMatcherFactories = {
337337 isApproximately : ( ) => ( {
338338 compare : ( actual : number , expected : number ) => {
339339 const result = {
@@ -348,6 +348,14 @@ const approximateMatcher = {
348348 } ) ,
349349} ;
350350
351+ interface NumberMatchers extends jasmine . Matchers < number > {
352+ isApproximately ( expected : number ) : void ;
353+ not : NumberMatchers ;
354+ }
355+ declare global {
356+ function expect ( actual : number ) : NumberMatchers ;
357+ }
358+
351359const testCases = [
352360 [ MatColumnResizeModule , MatResizeTest , 'opt-in table-based mat-table' ] ,
353361 [ MatColumnResizeModule , MatResizeOnPushTest , 'inside OnPush component' ] ,
@@ -409,12 +417,8 @@ describe('Material Popover Edit', () => {
409417 component . getOverlayThumbElement ( 2 ) . classList . contains ( 'mat-column-resize-overlay-thumb' ) ,
410418 ) . toBe ( true ) ;
411419
412- ( expect ( component . getOverlayThumbElement ( 0 ) . offsetHeight ) as any ) . isApproximately (
413- headerRowHeight ,
414- ) ;
415- ( expect ( component . getOverlayThumbElement ( 2 ) . offsetHeight ) as any ) . isApproximately (
416- headerRowHeight ,
417- ) ;
420+ expect ( component . getOverlayThumbElement ( 0 ) . offsetHeight ) . isApproximately ( headerRowHeight ) ;
421+ expect ( component . getOverlayThumbElement ( 2 ) . offsetHeight ) . isApproximately ( headerRowHeight ) ;
418422
419423 component . beginColumnResizeWithMouse ( 0 ) ;
420424
@@ -425,15 +429,11 @@ describe('Material Popover Edit', () => {
425429 component . getOverlayThumbElement ( 2 ) . classList . contains ( 'mat-column-resize-overlay-thumb' ) ,
426430 ) . toBe ( true ) ;
427431
428- ( expect ( component . getOverlayThumbElement ( 0 ) . offsetHeight ) as any ) . isApproximately (
429- tableHeight ,
430- ) ;
431- ( expect ( component . getOverlayThumbTopElement ( 0 ) . offsetHeight ) as any ) . isApproximately (
432- headerRowHeight ,
433- ) ;
434- ( expect ( component . getOverlayThumbElement ( 2 ) . offsetHeight ) as any ) . isApproximately (
432+ expect ( component . getOverlayThumbElement ( 0 ) . offsetHeight ) . isApproximately ( tableHeight ) ;
433+ expect ( component . getOverlayThumbTopElement ( 0 ) . offsetHeight ) . isApproximately (
435434 headerRowHeight ,
436435 ) ;
436+ expect ( component . getOverlayThumbElement ( 2 ) . offsetHeight ) . isApproximately ( headerRowHeight ) ;
437437
438438 component . completeResizeWithMouseInProgress ( 0 ) ;
439439 component . endHoverState ( ) ;
@@ -462,31 +462,31 @@ describe('Material Popover Edit', () => {
462462 let columnPositionDelta = component . getColumnOriginPosition ( 1 ) - initialColumnPosition ;
463463 // let nextColumnPositionDelta =
464464 // component.getColumnOriginPosition(2) - initialNextColumnPosition;
465- ( expect ( thumbPositionDelta ) as any ) . isApproximately ( columnPositionDelta ) ;
465+ expect ( thumbPositionDelta ) . isApproximately ( columnPositionDelta ) ;
466466 // TODO: This was commented out after switching from the legacy table to the current
467467 // MDC-based table. This failed by being inaccurate by several pixels.
468- // ( expect(nextColumnPositionDelta) as any ).isApproximately(columnPositionDelta);
468+ // expect(nextColumnPositionDelta).isApproximately(columnPositionDelta);
469469
470470 // TODO: This was commented out after switching from the legacy table to the current
471471 // MDC-based table. This failed by being inaccurate by several pixels.
472- // ( expect(component.getTableWidth()) as any ).isApproximately(initialTableWidth + 5);
473- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 5 ) ;
472+ // expect(component.getTableWidth()).isApproximately(initialTableWidth + 5);
473+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 5 ) ;
474474
475475 component . updateResizeWithMouseInProgress ( 1 ) ;
476476 fixture . detectChanges ( ) ;
477477 flush ( ) ;
478478
479479 thumbPositionDelta = component . getOverlayThumbPosition ( 1 ) - initialThumbPosition ;
480480 columnPositionDelta = component . getColumnOriginPosition ( 1 ) - initialColumnPosition ;
481- ( expect ( thumbPositionDelta ) as any ) . isApproximately ( columnPositionDelta ) ;
481+ expect ( thumbPositionDelta ) . isApproximately ( columnPositionDelta ) ;
482482
483- ( expect ( component . getTableWidth ( ) ) as any ) . isApproximately ( initialTableWidth + 1 ) ;
484- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 1 ) ;
483+ expect ( component . getTableWidth ( ) ) . isApproximately ( initialTableWidth + 1 ) ;
484+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 1 ) ;
485485
486486 component . completeResizeWithMouseInProgress ( 1 ) ;
487487 flush ( ) ;
488488
489- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 1 ) ;
489+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 1 ) ;
490490
491491 component . endHoverState ( ) ;
492492 fixture . detectChanges ( ) ;
@@ -508,23 +508,23 @@ describe('Material Popover Edit', () => {
508508 flush ( ) ;
509509
510510 let thumbPositionDelta = component . getOverlayThumbPosition ( 1 ) - initialThumbPosition ;
511- ( expect ( thumbPositionDelta ) as any ) . isApproximately ( 5 ) ;
512- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . toBe ( initialColumnWidth ) ;
511+ expect ( thumbPositionDelta ) . isApproximately ( 5 ) ;
512+ expect ( component . getColumnWidth ( 1 ) ) . toBe ( initialColumnWidth ) ;
513513
514514 component . updateResizeWithMouseInProgress ( 1 ) ;
515515 fixture . detectChanges ( ) ;
516516 flush ( ) ;
517517
518518 thumbPositionDelta = component . getOverlayThumbPosition ( 1 ) - initialThumbPosition ;
519519
520- ( expect ( component . getTableWidth ( ) ) as any ) . toBe ( initialTableWidth ) ;
521- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . toBe ( initialColumnWidth ) ;
520+ expect ( component . getTableWidth ( ) ) . toBe ( initialTableWidth ) ;
521+ expect ( component . getColumnWidth ( 1 ) ) . toBe ( initialColumnWidth ) ;
522522
523523 component . completeResizeWithMouseInProgress ( 1 ) ;
524524 flush ( ) ;
525525
526- ( expect ( component . getTableWidth ( ) ) as any ) . isApproximately ( initialTableWidth + 1 ) ;
527- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 1 ) ;
526+ expect ( component . getTableWidth ( ) ) . isApproximately ( initialTableWidth + 1 ) ;
527+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 1 ) ;
528528
529529 component . endHoverState ( ) ;
530530 fixture . detectChanges ( ) ;
@@ -562,18 +562,18 @@ describe('Material Popover Edit', () => {
562562
563563 let thumbPositionDelta = component . getOverlayThumbPosition ( 1 ) - initialThumbPosition ;
564564 let columnPositionDelta = component . getColumnOriginPosition ( 1 ) - initialColumnPosition ;
565- ( expect ( thumbPositionDelta ) as any ) . isApproximately ( columnPositionDelta ) ;
565+ expect ( thumbPositionDelta ) . isApproximately ( columnPositionDelta ) ;
566566
567- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth + 5 ) ;
567+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth + 5 ) ;
568568 // TODO: This was commented out after switching from the legacy table to the current
569569 // MDC-based table. This failed by being inaccurate by several pixels.
570- // ( expect(component.getTableWidth()) as any ).isApproximately(initialTableWidth + 5);
570+ // expect(component.getTableWidth()).isApproximately(initialTableWidth + 5);
571571
572572 dispatchKeyboardEvent ( document , 'keyup' , ESCAPE ) ;
573573 flush ( ) ;
574574
575- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( initialColumnWidth ) ;
576- ( expect ( component . getTableWidth ( ) ) as any ) . isApproximately ( initialTableWidth ) ;
575+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( initialColumnWidth ) ;
576+ expect ( component . getTableWidth ( ) ) . isApproximately ( initialTableWidth ) ;
577577
578578 component . endHoverState ( ) ;
579579 fixture . detectChanges ( ) ;
@@ -582,7 +582,7 @@ describe('Material Popover Edit', () => {
582582 it ( 'notifies subscribers of a completed resize via ColumnResizeNotifier' , fakeAsync ( ( ) => {
583583 const initialColumnWidth = component . getColumnWidth ( 1 ) ;
584584
585- let resize : ColumnSize | null = null ;
585+ let resize : ColumnSize | null = null as ColumnSize | null ;
586586 component . columnResize . columnResizeNotifier . resizeCompleted . subscribe ( size => {
587587 resize = size ;
588588 } ) ;
@@ -596,7 +596,7 @@ describe('Material Popover Edit', () => {
596596 fixture . detectChanges ( ) ;
597597 flush ( ) ;
598598
599- expect ( resize ) . toEqual ( { columnId : 'name' , size : initialColumnWidth + 5 } as any ) ;
599+ expect ( resize ) . toEqual ( { columnId : 'name' , size : initialColumnWidth + 5 } ) ;
600600
601601 component . endHoverState ( ) ;
602602 fixture . detectChanges ( ) ;
@@ -626,12 +626,12 @@ describe('Material Popover Edit', () => {
626626
627627 it ( 'performs a column resize triggered via ColumnResizeNotifier' , fakeAsync ( ( ) => {
628628 // Pre-verify that we are not updating the size to the initial size.
629- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . not . isApproximately ( 173 ) ;
629+ expect ( component . getColumnWidth ( 1 ) ) . not . isApproximately ( 173 ) ;
630630
631631 component . columnResize . columnResizeNotifier . resize ( 'name' , 173 ) ;
632632 flush ( ) ;
633633
634- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( 173 ) ;
634+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( 173 ) ;
635635 } ) ) ;
636636 } ) ;
637637 }
@@ -660,13 +660,13 @@ describe('Material Popover Edit', () => {
660660 } ) ) ;
661661
662662 it ( 'applies the persisted size' , fakeAsync ( ( ) => {
663- ( expect ( component . getColumnWidth ( 1 ) ) . not as any ) . isApproximately ( 300 ) ;
663+ expect ( component . getColumnWidth ( 1 ) ) . not . isApproximately ( 300 ) ;
664664
665665 columnSizeStore . emitSize ( 'theTable' , 'name' , 300 ) ;
666666
667667 flush ( ) ;
668668
669- ( expect ( component . getColumnWidth ( 1 ) ) as any ) . isApproximately ( 300 ) ;
669+ expect ( component . getColumnWidth ( 1 ) ) . isApproximately ( 300 ) ;
670670 } ) ) ;
671671
672672 it ( 'persists the user-triggered size update' , fakeAsync ( ( ) => {
@@ -689,7 +689,7 @@ describe('Material Popover Edit', () => {
689689 const { tableId, columnId, sizePx} = columnSizeStore . setSizeCalls [ 0 ] ;
690690 expect ( tableId ) . toBe ( 'theTable' ) ;
691691 expect ( columnId ) . toBe ( 'name' ) ;
692- ( expect ( sizePx ) as any ) . isApproximately ( initialColumnWidth + 5 ) ;
692+ expect ( sizePx ) . isApproximately ( initialColumnWidth + 5 ) ;
693693 } ) ) ;
694694
695695 it ( 'persists the user-triggered size update (live updates off)' , fakeAsync ( ( ) => {
@@ -714,7 +714,7 @@ describe('Material Popover Edit', () => {
714714 const { tableId, columnId, sizePx} = columnSizeStore . setSizeCalls [ 0 ] ;
715715 expect ( tableId ) . toBe ( 'theTable' ) ;
716716 expect ( columnId ) . toBe ( 'name' ) ;
717- ( expect ( sizePx ) as any ) . isApproximately ( initialColumnWidth + 5 ) ;
717+ expect ( sizePx ) . isApproximately ( initialColumnWidth + 5 ) ;
718718 } ) ) ;
719719 } ) ;
720720} ) ;
0 commit comments