@@ -30,7 +30,7 @@ import type {
3030 Module ,
3131 ModuleWrapper ,
3232} from '@jest/environment' ;
33- import { LegacyFakeTimers , ModernFakeTimers } from '@jest/fake-timers' ;
33+ import type { LegacyFakeTimers , ModernFakeTimers } from '@jest/fake-timers' ;
3434import type * as JestGlobals from '@jest/globals' ;
3535import type { SourceMapRegistry } from '@jest/source-map' ;
3636import type { RuntimeTransformResult , V8CoverageResult } from '@jest/test-result' ;
@@ -1961,8 +1961,11 @@ export default class Runtime {
19611961 getRealSystemTime : ( ) => {
19621962 const fakeTimers = _getFakeTimers ( ) ;
19631963
1964- if ( fakeTimers instanceof ModernFakeTimers ) {
1965- return fakeTimers . getRealSystemTime ( ) ;
1964+ if (
1965+ typeof ( fakeTimers as ModernFakeTimers ) . getRealSystemTime ===
1966+ 'function'
1967+ ) {
1968+ return ( fakeTimers as ModernFakeTimers ) . getRealSystemTime ( ) ;
19661969 } else {
19671970 throw new TypeError (
19681971 'getRealSystemTime is not available when not using modern timers' ,
@@ -1982,8 +1985,11 @@ export default class Runtime {
19821985 runAllImmediates : ( ) => {
19831986 const fakeTimers = _getFakeTimers ( ) ;
19841987
1985- if ( fakeTimers instanceof LegacyFakeTimers ) {
1986- fakeTimers . runAllImmediates ( ) ;
1988+ if (
1989+ typeof ( fakeTimers as LegacyFakeTimers < unknown > ) . runAllImmediates ===
1990+ 'function'
1991+ ) {
1992+ ( fakeTimers as LegacyFakeTimers < unknown > ) . runAllImmediates ( ) ;
19871993 } else {
19881994 throw new TypeError (
19891995 'runAllImmediates is not available when using modern timers' ,
@@ -1998,8 +2004,10 @@ export default class Runtime {
19982004 setSystemTime : ( now ?: number | Date ) => {
19992005 const fakeTimers = _getFakeTimers ( ) ;
20002006
2001- if ( fakeTimers instanceof ModernFakeTimers ) {
2002- fakeTimers . setSystemTime ( now ) ;
2007+ if (
2008+ typeof ( fakeTimers as ModernFakeTimers ) . setSystemTime === 'function'
2009+ ) {
2010+ ( fakeTimers as ModernFakeTimers ) . setSystemTime ( now ) ;
20032011 } else {
20042012 throw new TypeError (
20052013 'setSystemTime is not available when not using modern timers' ,
0 commit comments