diff --git a/src/libs/BootSplash/index.native.js b/src/libs/BootSplash/index.native.ts similarity index 91% rename from src/libs/BootSplash/index.native.js rename to src/libs/BootSplash/index.native.ts index 942b3cadb74a..0790b4de89bc 100644 --- a/src/libs/BootSplash/index.native.js +++ b/src/libs/BootSplash/index.native.ts @@ -3,7 +3,7 @@ import Log from '../Log'; const BootSplash = NativeModules.BootSplash; -function hide() { +function hide(): Promise { Log.info('[BootSplash] hiding splash screen', false); return BootSplash.hide(); } diff --git a/src/libs/BootSplash/index.js b/src/libs/BootSplash/index.ts similarity index 62% rename from src/libs/BootSplash/index.js rename to src/libs/BootSplash/index.ts index c169f380a8eb..24842fe631f4 100644 --- a/src/libs/BootSplash/index.js +++ b/src/libs/BootSplash/index.ts @@ -1,20 +1,21 @@ import Log from '../Log'; +import {VisibilityStatus} from './types'; -function resolveAfter(delay) { - return new Promise((resolve) => setTimeout(resolve, delay)); +function resolveAfter(delay: number): Promise { + return new Promise((resolve) => setTimeout(resolve, delay)); } -function hide() { +function hide(): Promise { Log.info('[BootSplash] hiding splash screen', false); return document.fonts.ready.then(() => { const splash = document.getElementById('splash'); if (splash) { - splash.style.opacity = 0; + splash.style.opacity = '0'; } return resolveAfter(250).then(() => { - if (!splash || !splash.parentNode) { + if (!splash?.parentNode) { return; } splash.parentNode.removeChild(splash); @@ -22,7 +23,7 @@ function hide() { }); } -function getVisibilityStatus() { +function getVisibilityStatus(): Promise { return Promise.resolve(document.getElementById('splash') ? 'visible' : 'hidden'); } diff --git a/src/libs/BootSplash/types.ts b/src/libs/BootSplash/types.ts new file mode 100644 index 000000000000..2329d5315817 --- /dev/null +++ b/src/libs/BootSplash/types.ts @@ -0,0 +1,9 @@ +type VisibilityStatus = 'visible' | 'hidden'; + +type BootSplashModule = { + navigationBarHeight: number; + hide: () => Promise; + getVisibilityStatus: () => Promise; +}; + +export type {BootSplashModule, VisibilityStatus}; diff --git a/src/types/modules/react-native.d.ts b/src/types/modules/react-native.d.ts index 1b0b39e5f67d..ebe0974db690 100644 --- a/src/types/modules/react-native.d.ts +++ b/src/types/modules/react-native.d.ts @@ -1,9 +1,14 @@ /* eslint-disable @typescript-eslint/consistent-type-definitions */ import 'react-native'; +import {BootSplashModule} from '../../libs/BootSplash/types'; declare module 'react-native' { interface TextInput { // Typescript type declaration is missing in React Native for setting text selection. setSelection: (start: number, end: number) => void; } + + interface NativeModulesStatic { + BootSplash: BootSplashModule; + } }