Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] [TS migration] Migrate 'StartupTimer' lib to TypeScript #26771

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
3 changes: 3 additions & 0 deletions src/libs/StartupTimer/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type StartupTimerStop = () => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// types.ts
type StartupTimer = {
    stop: () => void;
};

// index.native.ts
const startupTimer: StartupTimer = {
    stop: () => {
        NativeModules.StartupTimer.stop();
    },
};

// index.ts
const startupTimer: StartupTimer = {
    stop: () => {},
};

export default startupTimer;

What about defining StartupTimer type as a object with stop function? It would be better and more stricter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! @fabioh8010 :)


export default StartupTimerStop;
Loading