Skip to content

Commit c2b797c

Browse files
committed
Fix all typescript errors
1 parent e8bfea4 commit c2b797c

30 files changed

+106
-100
lines changed

src/actions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
scrollTo,
66
scrollToEnd,
77
toExist,
8-
} from './actions';
9-
import * as websocket from './websocket';
8+
} from '../actions';
9+
import * as websocket from '../websocket';
1010

1111
describe('actions.ts', () => {
1212
let onMessageCallback: (onMessage: (message: string) => void) => void;

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: 6 additions & 6 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

4-
import { buildAndroid, buildHandler, buildIOS, ENTRY_FILE } from './build';
5-
import { CliBuildOptions, Config, ConfigEnv } from '../types';
6-
import { Logger } from '../logger';
7-
import * as configHelpers from './config';
4+
import { buildAndroid, buildHandler, buildIOS, ENTRY_FILE } from '../../cli/build';
5+
import type { CliBuildOptions, Config, ConfigEnv } from '../../types';
6+
import { Logger } from '../../logger';
7+
import * as configHelpers from '../../cli/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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { promises as fs } from 'fs';
22

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

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

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: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { promises as fs } from 'fs';
22
import path from 'path';
3-
import * as reportHelpers from '../report';
4-
import * as configHelpers from './config';
3+
import * as reportHelpers from '../../report';
4+
import * as configHelpers from '../../cli/config';
55

6-
import { CliRunOptions, Config } from '../types';
7-
import * as run from './run';
8-
import * as xcrun from '../utils/xcrun';
9-
import * as adb from '../utils/adb';
10-
import execa from 'execa';
11-
import { Logger } from '../logger';
6+
import type { CliRunOptions, Config } from '../../types';
7+
import * as run from '../../cli/run';
8+
import * as xcrun from '../../utils/xcrun';
9+
import * as adb from '../../utils/adb';
10+
import * as execa from 'execa';
11+
import { execaCommand } from 'execa';
12+
import { Logger } from '../../logger';
1213

1314
jest.mock('../utils/xcrun');
1415
jest.mock('../utils/adb');
@@ -21,9 +22,9 @@ describe('run.ts', () => {
2122
const mkdirMock = jest.spyOn(fs, 'mkdir');
2223
const execKillMock = {
2324
kill: jest.fn(),
24-
} as unknown as execa.ExecaChildProcess<any>;
25+
} as unknown as ReturnType<typeof execaCommand>;
2526

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

2829
beforeEach(() => {
2930
mkdirMock.mockReset();
@@ -153,7 +154,7 @@ describe('run.ts', () => {
153154
process.cwd()
154155
)} --runInBand`;
155156

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

159160
jest.spyOn(Logger.prototype, 'print').mockImplementation();
@@ -245,7 +246,7 @@ describe('run.ts', () => {
245246

246247
await run.runHandler({ ...args });
247248

248-
await expect(execMock.mock.calls[0][0]).toEqual(
249+
await expect(execMock.mock.calls[0]?.[0]).toEqual(
249250
'node scripts/websocket-server.js'
250251
);
251252
});

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

0 commit comments

Comments
 (0)