Skip to content

Commit 2bbfaf1

Browse files
committed
Fix all typescript errors
1 parent e8bfea4 commit 2bbfaf1

22 files changed

+73
-68
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import path from 'path';
2-
import execa from 'execa';
2+
import * as 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

99
describe('build.ts', () => {
1010
const logger = new Logger();
11-
const execMock = jest.spyOn(execa, 'command').mockImplementation();
11+
const execMock = jest.spyOn(execa, 'execaCommand').mockImplementation();
1212

1313
beforeEach(() => {
1414
execMock.mockReset();

src/cli/build.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path';
2-
import execa from 'execa';
2+
import { execaCommand } 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

@@ -29,7 +29,7 @@ export const buildIOS = async (
2929

3030
logger.info(`[OWL - CLI] Building the app with: ${buildCommand.join(' ')}.`);
3131

32-
await execa.command(buildCommand.join(' '), {
32+
await execaCommand(buildCommand.join(' '), {
3333
stdio: 'inherit',
3434
env: {
3535
ENTRY_FILE,
@@ -65,7 +65,7 @@ export const buildAndroid = async (
6565

6666
logger.info(`[OWL - CLI] Building the app with: ${buildCommand.join(' ')}.`);
6767

68-
await execa.command(buildCommand.join(' '), {
68+
await execaCommand(buildCommand.join(' '), {
6969
stdio: 'inherit',
7070
cwd,
7171
env: {

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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
2-
import yargs, { Options } from 'yargs';
3-
import { CliBuildOptions, CliRunOptions } from '../types';
4-
const { hideBin } = require('yargs/helpers');
2+
import yargs, { type Options } from 'yargs';
3+
import type { CliBuildOptions, CliRunOptions } from '../types';
4+
import { hideBin } from 'yargs/helpers';
55
const argv = yargs(hideBin(process.argv));
66

77
import { buildHandler } from './build';

src/cli/run.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ 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';
10-
import execa from 'execa';
10+
import * as execa from 'execa';
1111
import { Logger } from '../logger';
1212

1313
jest.mock('../utils/xcrun');
@@ -21,9 +21,9 @@ describe('run.ts', () => {
2121
const mkdirMock = jest.spyOn(fs, 'mkdir');
2222
const execKillMock = {
2323
kill: jest.fn(),
24-
} as unknown as execa.ExecaChildProcess<any>;
24+
} as unknown as ReturnType<typeof execa.execaCommand>;
2525

26-
const execMock = jest.spyOn(execa, 'command').mockImplementation();
26+
const execMock = jest.spyOn(execa, 'execaCommand').mockReturnValue(execKillMock);
2727

2828
beforeEach(() => {
2929
mkdirMock.mockReset();
@@ -153,7 +153,7 @@ describe('run.ts', () => {
153153
process.cwd()
154154
)} --runInBand`;
155155

156-
const commandSyncMock = jest.spyOn(execa, 'commandSync');
156+
const commandSyncMock = jest.spyOn(execa, 'execaCommandSync');
157157
const mockGenerateReport = jest.spyOn(reportHelpers, 'generateReport');
158158

159159
jest.spyOn(Logger.prototype, 'print').mockImplementation();
@@ -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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import path from 'path';
2-
import execa from 'execa';
2+
import { execaCommand, execaCommandSync } 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';
@@ -102,7 +102,7 @@ export const runHandler = async (args: CliRunOptions) => {
102102
await cleanupScreenshots();
103103

104104
logger.print(`[OWL - CLI] Starting websocket server.`);
105-
const webSocketProcess = execa.command('node scripts/websocket-server.js', {
105+
const webSocketProcess = execaCommand('node scripts/websocket-server.js', {
106106
stdio: 'inherit',
107107
cwd: path.join(__dirname, '..', '..'),
108108
env: {
@@ -149,7 +149,7 @@ export const runHandler = async (args: CliRunOptions) => {
149149
logger.info(`[OWL - CLI] Will set the jest root to ${process.cwd()}.`);
150150

151151
try {
152-
await execa.commandSync(jestCommand, {
152+
await execaCommandSync(jestCommand, {
153153
stdio: 'inherit',
154154
env: {
155155
OWL_PLATFORM: args.platform,

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 are mocking the event object
2526
currentTarget: 0,
27+
// @ts-expect-error - We are mocking the event object
2628
target: 0,
2729
bubbles: false,
2830
cancelable: false,

0 commit comments

Comments
 (0)