From c68505cf245b3dddc2e43239632ba50a238a4059 Mon Sep 17 00:00:00 2001 From: Sean Dawson Date: Thu, 6 Aug 2020 08:15:27 +1000 Subject: [PATCH] chore: add exemptions for type-coverage - In these cases we know what the source data is so it is OK for now but in the future we should add some proper validation re #90 --- src/app/background.ts | 1 + src/app/plugin.ts | 1 + src/app/scms/bitbucket-server/scraper.ts | 6 ++++-- src/app/scms/bitbucket-server/ui.ts | 6 ++++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/background.ts b/src/app/background.ts index 6a51adce..d6a42651 100644 --- a/src/app/background.ts +++ b/src/app/background.ts @@ -56,6 +56,7 @@ const updateButtonState = async () => { browser.runtime.onMessage.addListener( async (rawMessage: unknown, sender: Runtime.MessageSender) => { + // type-coverage:ignore-next-line const message = rawMessage as Message; if (sender.tab === undefined) { return; diff --git a/src/app/plugin.ts b/src/app/plugin.ts index 0703e432..d5129b8a 100644 --- a/src/app/plugin.ts +++ b/src/app/plugin.ts @@ -16,6 +16,7 @@ export const init = (bitbucketServerScmModule: ScmModule) => { browser.runtime.onMessage.addListener( async (rawMessage: unknown, sender: Runtime.MessageSender) => { + // type-coverage:ignore-next-line const message = rawMessage as Message; console.log( `[Mule Preview] Received message from [${sender}]: [${JSON.stringify( diff --git a/src/app/scms/bitbucket-server/scraper.ts b/src/app/scms/bitbucket-server/scraper.ts index 3e28c771..3ce911bd 100644 --- a/src/app/scms/bitbucket-server/scraper.ts +++ b/src/app/scms/bitbucket-server/scraper.ts @@ -11,8 +11,9 @@ import { MessageType } from "~app/types/messenging"; // browser so it should be free of dependencies and small as possible (() => { const isPullRequest = ( - pageState: unknown + pageState: CommonPageState ): pageState is PullRequestPageState => { + // type-coverage:ignore-next-line const prPageState = pageState as PullRequestPageState; return ( prPageState.getPullRequest !== undefined && @@ -20,7 +21,8 @@ import { MessageType } from "~app/types/messenging"; ); }; - const isDiff = (pageState: unknown): pageState is DiffPageState => { + const isDiff = (pageState: CommonPageState): pageState is DiffPageState => { + // type-coverage:ignore-next-line const diffPageState = pageState as DiffPageState; return ( diffPageState.getSourceRepository !== undefined && diff --git a/src/app/scms/bitbucket-server/ui.ts b/src/app/scms/bitbucket-server/ui.ts index d9930c0d..a463e686 100644 --- a/src/app/scms/bitbucket-server/ui.ts +++ b/src/app/scms/bitbucket-server/ui.ts @@ -39,12 +39,14 @@ export const getCurrentFile = () => { export const getBitbucketData = async (): Promise => { return new Promise((resolve, reject) => { + // TODO: Work out why there is a force cast to EventListener here + // type-coverage:ignore-next-line document.addEventListener("BitbucketDataScraped", (( event: CustomEvent ) => { - console.log(`Recieved ["BitbucketDataScraped"] event!`); + console.log(`Received ["BitbucketDataScraped"] event!`); resolve(event.detail); - }) as EventListener); + }) as EventListener); setTimeout( () => reject(new Error("Took too long to scrape Bitbucket data")), 1000