Skip to content

Commit 862ab9b

Browse files
committed
Fix all typescript errors
1 parent d96bd4b commit 862ab9b

19 files changed

+36
-32
lines changed

src/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { getConfig } from './cli/config';
22

33
import { Logger } from './logger';
4-
import { CliRunOptions } from './types';
4+
import type { CliRunOptions } from './types';
55
import { adbLaunch, adbTerminate } from './utils/adb';
66
import { waitFor } from './utils/wait-for';
77
import { xcrunLaunch, xcrunTerminate, xcrunUi } from './utils/xcrun';
88
import { createWebSocketClient } from './websocket';
9-
import {
9+
import type {
1010
SOCKET_TEST_REQUEST,
1111
SOCKET_SCROLL_TO_VALUE,
1212
SOCKET_CLIENT_RESPONSE,

src/cli/build.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path';
22
import execa from 'execa';
33

44
import { buildAndroid, buildHandler, buildIOS, ENTRY_FILE } from './build';
5-
import { CliBuildOptions, Config, ConfigEnv } from '../types';
5+
import type { CliBuildOptions, Config, ConfigEnv } from '../types';
66
import { Logger } from '../logger';
77
import * as configHelpers from './config';
88

src/cli/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path';
22
import execa from 'execa';
33

4-
import { CliBuildOptions, Config } from '../types';
4+
import type { CliBuildOptions, Config } from '../types';
55
import { Logger } from '../logger';
66
import { getConfig } from './config';
77

src/cli/config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { promises as fs } from 'fs';
22

3-
import { Config } from '../types';
3+
import type { Config } from '../types';
44
import { getConfig, readConfigFile, validateSchema } from './config';
55

66
describe('config.ts', () => {

src/cli/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { promises as fs } from 'fs';
2-
import Ajv, { ErrorObject, JSONSchemaType } from 'ajv';
2+
import Ajv, { type ErrorObject, type JSONSchemaType } from 'ajv';
33

4-
import { Config } from '../types';
4+
import type { Config } from '../types';
55

66
export const validateSchema = (config: {}): Promise<Config> => {
77
const configSchema: JSONSchemaType<Config> = {

src/cli/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env node
2-
import yargs, { Options } from 'yargs';
3-
import { CliBuildOptions, CliRunOptions } from '../types';
4-
const { hideBin } = require('yargs/helpers');
5-
const argv = yargs(hideBin(process.argv));
2+
import yargs, { type Options } from 'yargs';
3+
import type { CliBuildOptions, CliRunOptions } from '../types';
4+
import { hideBin } from 'yargs/helpers';
65

76
import { buildHandler } from './build';
87
import { runHandler } from './run';
98

9+
const argv = yargs(hideBin(process.argv));
10+
1011
const plaformOption: Options = {
1112
alias: 'p',
1213
describe: 'Platform to build and run the app',

src/cli/run.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'path';
33
import * as reportHelpers from '../report';
44
import * as configHelpers from './config';
55

6-
import { CliRunOptions, Config } from '../types';
6+
import type { CliRunOptions, Config } from '../types';
77
import * as run from './run';
88
import * as xcrun from '../utils/xcrun';
99
import * as adb from '../utils/adb';
@@ -245,7 +245,7 @@ describe('run.ts', () => {
245245

246246
await run.runHandler({ ...args });
247247

248-
await expect(execMock.mock.calls[0][0]).toEqual(
248+
await expect(execMock.mock.calls[0]?.[0]).toEqual(
249249
'node scripts/websocket-server.js'
250250
);
251251
});

src/cli/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import execa from 'execa';
33
import { promises as fs } from 'fs';
44

55
import { cleanupScreenshots } from '../screenshot';
6-
import { CliRunOptions, Config } from '../types';
6+
import type { CliRunOptions, Config } from '../types';
77
import { generateReport, cleanupReport } from '../report';
88
import { getConfig } from './config';
99
import { Logger } from '../logger';

src/client/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
SOCKET_WAIT_TIMEOUT,
88
} from './constants';
99
import { initWebSocket } from './websocket';
10-
import { SOCKET_CLIENT_RESPONSE, SOCKET_TEST_REQUEST } from '../websocketTypes';
10+
import type { SOCKET_CLIENT_RESPONSE, SOCKET_TEST_REQUEST } from '../websocketTypes';
1111

12-
import { add, get, TrackedElementData } from './trackedElements';
12+
import { add, get, type TrackedElementData } from './trackedElements';
1313
import { handleAction } from './handleAction';
1414

1515
const logger = new Logger(true);
@@ -115,9 +115,9 @@ export const applyJsxChildrenElementTracking = (props: any): void => {
115115
export const patchReact = () => {
116116
const originalReactCreateElement: typeof React.createElement =
117117
React.createElement;
118-
let automateTimeout: number;
118+
let automateTimeout: NodeJS.Timeout;
119119

120-
if (parseInt(React.version.split('.')[0], 10) >= 18) {
120+
if (parseInt(React.version.split('.')?.[0] || '0', 10) >= 18) {
121121
const jsxRuntime = require('react/jsx-runtime');
122122
const origJsx = jsxRuntime.jsx;
123123

src/client/handleAction.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { GestureResponderEvent } from 'react-native';
2-
import {
1+
import type { GestureResponderEvent } from 'react-native';
2+
import type {
33
SOCKET_TEST_ACTION,
44
SOCKET_TEST_REQUEST_VALUE,
55
} from '../websocketTypes';
66
import { Logger } from '../logger';
7-
import { TrackedElementData } from './trackedElements';
7+
import type { TrackedElementData } from './trackedElements';
88

99
/**
1010
* When we call onPress/onLongPress, the function expects an `event` arg of type `GestureResponderEvent`.
@@ -22,7 +22,9 @@ const getGestureResponderEvent = (): GestureResponderEvent => ({
2222
timestamp: Date.now(),
2323
touches: [],
2424
},
25+
// @ts-expect-error - We're mocking the event object, so we don't need to match the full type
2526
currentTarget: 0,
27+
// @ts-expect-error - We're mocking the event object, so we don't need to match the full type
2628
target: 0,
2729
bubbles: false,
2830
cancelable: false,

0 commit comments

Comments
 (0)