Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TypeScript errors not showing up in CI
Browse files Browse the repository at this point in the history
watson committed Nov 12, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 374d6f4 commit f5d6572
Showing 10 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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({
Original file line number Diff line number Diff line change
@@ -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
@@ -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}/`)
);
}
Original file line number Diff line number Diff line change
@@ -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'> &
Original file line number Diff line number Diff line change
@@ -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,
};
Original file line number Diff line number Diff line change
@@ -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');

@@ -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: () => {
Original file line number Diff line number Diff line change
@@ -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;
});

Original file line number Diff line number Diff line change
@@ -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;
});

0 comments on commit f5d6572

Please sign in to comment.