From 456c3f4f7aa6e285728d812ab6aaebd067f539dc Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Tue, 5 Sep 2023 14:39:22 +0200 Subject: [PATCH 1/3] [TS migration] Migrate 'StartupTimer' lib to TypeScript --- src/libs/StartupTimer/{index.native.js => index.native.ts} | 5 +++-- src/libs/StartupTimer/{index.js => index.ts} | 6 +++++- src/libs/StartupTimer/types.ts | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) rename src/libs/StartupTimer/{index.native.js => index.native.ts} (66%) rename src/libs/StartupTimer/{index.js => index.ts} (51%) create mode 100644 src/libs/StartupTimer/types.ts diff --git a/src/libs/StartupTimer/index.native.js b/src/libs/StartupTimer/index.native.ts similarity index 66% rename from src/libs/StartupTimer/index.native.js rename to src/libs/StartupTimer/index.native.ts index 29bbef8cfe3d..1a32278c14b6 100644 --- a/src/libs/StartupTimer/index.native.js +++ b/src/libs/StartupTimer/index.native.ts @@ -1,11 +1,12 @@ import {NativeModules} from 'react-native'; +import StartupTimerStop from './types'; /** * Stop the startup trace for the app. */ -function stop() { +const stop: StartupTimerStop = () => { NativeModules.StartupTimer.stop(); -} +}; export default { stop, diff --git a/src/libs/StartupTimer/index.js b/src/libs/StartupTimer/index.ts similarity index 51% rename from src/libs/StartupTimer/index.js rename to src/libs/StartupTimer/index.ts index 7b53266e50d9..bd80e82aaef3 100644 --- a/src/libs/StartupTimer/index.js +++ b/src/libs/StartupTimer/index.ts @@ -2,6 +2,10 @@ * Web noop as there is no "startup" to time from the native layer. */ +import StartupTimerStop from './types'; + +const stop: StartupTimerStop = () => {}; + export default { - stop() {}, + stop, }; diff --git a/src/libs/StartupTimer/types.ts b/src/libs/StartupTimer/types.ts new file mode 100644 index 000000000000..7e3a8bc91410 --- /dev/null +++ b/src/libs/StartupTimer/types.ts @@ -0,0 +1,3 @@ +type StartupTimerStop = () => void; + +export default StartupTimerStop; From b245f23126fdb2a17c459c62457ba29eb185fbb0 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Mon, 11 Sep 2023 14:07:57 +0200 Subject: [PATCH 2/3] Merge types into a single one --- src/libs/StartupTimer/index.native.ts | 10 +++++----- src/libs/StartupTimer/index.ts | 8 ++++---- src/libs/StartupTimer/types.ts | 4 +++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/libs/StartupTimer/index.native.ts b/src/libs/StartupTimer/index.native.ts index 1a32278c14b6..8f239e194979 100644 --- a/src/libs/StartupTimer/index.native.ts +++ b/src/libs/StartupTimer/index.native.ts @@ -4,10 +4,10 @@ import StartupTimerStop from './types'; /** * Stop the startup trace for the app. */ -const stop: StartupTimerStop = () => { - NativeModules.StartupTimer.stop(); +const startupTimer: StartupTimerStop = { + stop: () => { + NativeModules.StartupTimer.stop(); + }, }; -export default { - stop, -}; +export default startupTimer; diff --git a/src/libs/StartupTimer/index.ts b/src/libs/StartupTimer/index.ts index bd80e82aaef3..811183c9942d 100644 --- a/src/libs/StartupTimer/index.ts +++ b/src/libs/StartupTimer/index.ts @@ -4,8 +4,8 @@ import StartupTimerStop from './types'; -const stop: StartupTimerStop = () => {}; - -export default { - stop, +const startupTimer: StartupTimerStop = { + stop: () => {}, }; + +export default startupTimer; diff --git a/src/libs/StartupTimer/types.ts b/src/libs/StartupTimer/types.ts index 7e3a8bc91410..50479a8c0dd1 100644 --- a/src/libs/StartupTimer/types.ts +++ b/src/libs/StartupTimer/types.ts @@ -1,3 +1,5 @@ -type StartupTimerStop = () => void; +type StartupTimerStop = { + stop: () => void; +}; export default StartupTimerStop; From ee1bd673812cbc972c602cd82733f71d3482401c Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Mon, 11 Sep 2023 14:09:04 +0200 Subject: [PATCH 3/3] Rename type --- src/libs/StartupTimer/index.native.ts | 4 ++-- src/libs/StartupTimer/index.ts | 4 ++-- src/libs/StartupTimer/types.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/StartupTimer/index.native.ts b/src/libs/StartupTimer/index.native.ts index 8f239e194979..52ba55076fc1 100644 --- a/src/libs/StartupTimer/index.native.ts +++ b/src/libs/StartupTimer/index.native.ts @@ -1,10 +1,10 @@ import {NativeModules} from 'react-native'; -import StartupTimerStop from './types'; +import StartupTimer from './types'; /** * Stop the startup trace for the app. */ -const startupTimer: StartupTimerStop = { +const startupTimer: StartupTimer = { stop: () => { NativeModules.StartupTimer.stop(); }, diff --git a/src/libs/StartupTimer/index.ts b/src/libs/StartupTimer/index.ts index 811183c9942d..421524a70fc8 100644 --- a/src/libs/StartupTimer/index.ts +++ b/src/libs/StartupTimer/index.ts @@ -2,9 +2,9 @@ * Web noop as there is no "startup" to time from the native layer. */ -import StartupTimerStop from './types'; +import StartupTimer from './types'; -const startupTimer: StartupTimerStop = { +const startupTimer: StartupTimer = { stop: () => {}, }; diff --git a/src/libs/StartupTimer/types.ts b/src/libs/StartupTimer/types.ts index 50479a8c0dd1..e382fc267933 100644 --- a/src/libs/StartupTimer/types.ts +++ b/src/libs/StartupTimer/types.ts @@ -1,5 +1,5 @@ -type StartupTimerStop = { +type StartupTimer = { stop: () => void; }; -export default StartupTimerStop; +export default StartupTimer;