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

[TS migration] Migrate 'App.js' file to TypeScript #35242

Merged
merged 14 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"react-native-pdf": "6.7.3",
"react-native-performance": "^5.1.0",
"react-native-permissions": "^3.9.3",
"react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#7a407cd4174d9838a944c1c2e1cb4a9737ac69c5",
"react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#42b334d0c4e71d225601f72828d3dedd0bc22212",
mkhutornyi marked this conversation as resolved.
Show resolved Hide resolved
"react-native-plaid-link-sdk": "10.8.0",
"react-native-qrcode-svg": "^6.2.0",
"react-native-quick-sqlite": "^8.0.0-beta.2",
Expand Down
1 change: 1 addition & 0 deletions src/App.js → src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function App() {
<CustomStatusBarAndBackground />
<ErrorBoundary errorMessage="NewExpensify crash caught by error boundary">
<ColorSchemeWrapper>
{/* @ts-expect-error TODO: Remove this once Expensify (https://github.com/Expensify/App/issues/25231) is migrated to TypeScript. */}
<Expensify />
</ColorSchemeWrapper>
</ErrorBoundary>
Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomStatusBarAndBackground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import updateStatusBarAppearance from './updateStatusBarAppearance';
type CustomStatusBarAndBackgroundProps = {
/** Whether the CustomStatusBar is nested within another CustomStatusBar.
* A nested CustomStatusBar will disable the "root" CustomStatusBar. */
isNested: boolean;
isNested?: boolean;
};

function CustomStatusBarAndBackground({isNested = false}: CustomStatusBarAndBackgroundProps) {
Expand Down
8 changes: 0 additions & 8 deletions src/components/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
/* eslint-disable react/jsx-props-no-spreading */
import PropTypes from 'prop-types';
import React, {useMemo} from 'react';
import useThemePreferenceWithStaticOverride from '@hooks/useThemePreferenceWithStaticOverride';
// eslint-disable-next-line no-restricted-imports
import themes from '@styles/theme';
import ThemeContext from '@styles/theme/context/ThemeContext';
import type {ThemePreferenceWithoutSystem} from '@styles/theme/types';

const propTypes = {
/** Rendered child component */
children: PropTypes.node.isRequired,
};

type ThemeProviderProps = React.PropsWithChildren & {
theme?: ThemePreferenceWithoutSystem;
};
Expand All @@ -24,7 +17,6 @@ function ThemeProvider({children, theme: staticThemePreference}: ThemeProviderPr
return <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>;
}

ThemeProvider.propTypes = propTypes;
ThemeProvider.displayName = 'ThemeProvider';

export default ThemeProvider;
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import PropTypes from 'prop-types';
import React, {useEffect, useMemo, useRef} from 'react';
import useCurrentReportID from '@hooks/useCurrentReportID';
import type ChildrenProps from '@src/types/utils/ChildrenProps';

const ReportAttachmentsContext = React.createContext();

const propTypes = {
/** Rendered child component */
children: PropTypes.node.isRequired,
type ReportAttachmentsContextValue = {
isAttachmentHidden: (reportActionID: string) => boolean;
updateHiddenAttachments: (reportActionID: string, isHidden: boolean) => void;
};

function ReportAttachmentsProvider(props) {
const ReportAttachmentsContext = React.createContext<ReportAttachmentsContextValue>({
isAttachmentHidden: () => false,
updateHiddenAttachments: () => {},
});

function ReportAttachmentsProvider({children}: ChildrenProps) {
const currentReportID = useCurrentReportID();
const hiddenAttachments = useRef({});
const hiddenAttachments = useRef<Record<string, boolean>>({});

useEffect(() => {
// We only want to store the attachment visibility for the current report.
Expand All @@ -21,8 +24,8 @@ function ReportAttachmentsProvider(props) {

const contextValue = useMemo(
() => ({
isAttachmentHidden: (reportActionID) => hiddenAttachments.current[reportActionID],
updateHiddenAttachments: (reportActionID, value) => {
isAttachmentHidden: (reportActionID: string) => hiddenAttachments.current[reportActionID],
updateHiddenAttachments: (reportActionID: string, value: boolean) => {
hiddenAttachments.current = {
...hiddenAttachments.current,
[reportActionID]: value,
Expand All @@ -32,10 +35,9 @@ function ReportAttachmentsProvider(props) {
[],
);

return <ReportAttachmentsContext.Provider value={contextValue}>{props.children}</ReportAttachmentsContext.Provider>;
return <ReportAttachmentsContext.Provider value={contextValue}>{children}</ReportAttachmentsContext.Provider>;
}

ReportAttachmentsProvider.propTypes = propTypes;
ReportAttachmentsProvider.displayName = 'ReportAttachmentsProvider';

export default ReportAttachmentsContext;
Expand Down
2 changes: 2 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ declare module '*.lottie' {
interface Window {
enableMemoryOnlyKeys: () => void;
disableMemoryOnlyKeys: () => void;
setSupportToken: (token: string, email: string, accountID: number) => void;
Onyx: Record<string, unknown>;
}
mkhutornyi marked this conversation as resolved.
Show resolved Hide resolved
Loading