Skip to content

Commit

Permalink
use generic type with require
Browse files Browse the repository at this point in the history
  • Loading branch information
bgawkuc committed Jun 6, 2024
1 parent f4730ca commit 4f82ac1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions __mocks__/react-native-webview.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type {View as RNView} from 'react-native';

jest.mock('react-native-webview', () => {
const {View} = require('react-native');
const {View} = require<{View: RNView}>('react-native');
return {
WebView: () => View as RNView,
WebView: () => View,
};
});
2 changes: 1 addition & 1 deletion config/webpack/webpack.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type PreloadWebpackPluginClass = {
};

// require is necessary, there are no types for this package and the declaration file can't be seen by the build process which causes an error.
const PreloadWebpackPlugin: PreloadWebpackPluginClass = require('@vue/preload-webpack-plugin');
const PreloadWebpackPlugin = require<PreloadWebpackPluginClass>('@vue/preload-webpack-plugin');

const includeModules = [
'react-native-animatable',
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Performance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const Performance: PerformanceModule = {
};

if (Metrics.canCapturePerformanceMetrics()) {
const perfModule: ReactNativePerformance = require('react-native-performance');
const perfModule = require<ReactNativePerformance>('react-native-performance');
perfModule.setResourceLoggingEnabled(true);
rnPerformance = perfModule.default;

Expand Down
2 changes: 1 addition & 1 deletion wdyr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Config from 'react-native-config';
const useWDYR = Config?.USE_WDYR === 'true';

if (useWDYR) {
const whyDidYouRender: typeof WhyDidYouRender = require('@welldone-software/why-did-you-render');
const whyDidYouRender = require<typeof WhyDidYouRender>('@welldone-software/why-did-you-render');
whyDidYouRender(React, {
// Enable tracking in all pure components by default
trackAllPureComponents: true,
Expand Down

0 comments on commit 4f82ac1

Please sign in to comment.