Skip to content

Commit

Permalink
Fix TypeScript errors not showing up in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Nov 12, 2020
1 parent 374d6f4 commit f5d6572
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ const expectFileMatchesSnapshotWithCompression = (filePath: string, snapshotLabe

// Verify the brotli variant matches
expect(
// @ts-expect-error @types/node is missing the brotli functions
Zlib.brotliDecompressSync(
Fs.readFileSync(Path.resolve(MOCK_REPO_DIR, `${filePath}.br`))
).toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ async function slackExecutor(
// https://slack.dev/node-slack-sdk/webhook
// node-slack-sdk use Axios inside :)
const webhook = new IncomingWebhook(webhookUrl, {
// @ts-expect-error The types exposed by 'HttpsProxyAgent' isn't up to date with 'Agent'
agent: proxyAgent,
});
result = await webhook.send(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jest.mock('../../supported_renderers');
describe('Canvas Shareable Workpad API', () => {
// Mock the AJAX load of the workpad.
beforeEach(function () {
// @ts-expect-error Applying a global in Jest is alright.
global.fetch = jest.fn().mockImplementation(() => {
const p = new Promise((resolve, _reject) => {
resolve({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function getFetchOptions(targetUrl: string): RequestInit | undefined {
logger.debug(`Using ${proxyUrl} as proxy for ${targetUrl}`);

return {
// @ts-expect-error The types exposed by 'HttpsProxyAgent' isn't up to date with 'Agent'
agent: getProxyAgent({ proxyUrl, targetUrl }),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ export class HeadlessChromiumDriver {
hostname === conditions.hostname &&
protocol === `${conditions.protocol}:` &&
this._shouldUseCustomHeadersForPort(conditions, port) &&
// @ts-expect-error according to the types `pathname` is `string | undefined`, but it's actually `string | null`
pathname.startsWith(`${conditions.basePath}/`)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ type Exact<T, Shape> = T extends Shape ? ExactKeys<T, Shape> : never;
* Ensures that when creating a URL query param string, that the given input strictly
* matches the expected interface (guards against possibly leaking internal state)
*/
const querystringStringify: <ExpectedType, ArgType>(
const querystringStringify = <ExpectedType, ArgType>(
params: Exact<ExpectedType, ArgType>
) => string = querystring.stringify;
): string => querystring.stringify((params as unknown) as querystring.ParsedUrlQueryInput);

/** Make `selected_endpoint` required */
type EndpointDetailsUrlProps = Omit<EndpointIndexUIQueryParams, 'selected_endpoint'> &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EndpointIndexUIQueryParams } from '../types';
import { AppLocation } from '../../../../../common/endpoint/types';

export function urlFromQueryParams(queryParams: EndpointIndexUIQueryParams): Partial<AppLocation> {
const search = querystring.stringify(queryParams);
const search = querystring.stringify(queryParams as Record<string, string>);
return {
search,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import { NetworkDetails } from './index';
type Action = 'PUSH' | 'POP' | 'REPLACE';
const pop: Action = 'POP';

type GlobalWithFetch = NodeJS.Global & { fetch: jest.Mock };

jest.mock('react-router-dom', () => {
const original = jest.requireActual('react-router-dom');

Expand Down Expand Up @@ -85,7 +83,7 @@ describe('Network Details', () => {
indicesExist: false,
indexPattern: {},
});
(global as GlobalWithFetch).fetch = jest.fn().mockImplementationOnce(() =>
global.fetch = jest.fn().mockImplementationOnce(() =>
Promise.resolve({
ok: true,
json: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('SyntheticsCallout', () => {
setItem: setItemMock,
};

// @ts-expect-error replacing a call to localStorage we use for monitor list size
global.localStorage = localStorageMock;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ describe('MonitorList component', () => {
setItem: jest.fn(),
};

// @ts-expect-error replacing a call to localStorage we use for monitor list size
global.localStorage = localStorageMock;
});

Expand Down

0 comments on commit f5d6572

Please sign in to comment.