diff options
Diffstat (limited to 'source/features')
-rw-r--r-- | source/features/follow-file-renames.tsx | 4 | ||||
-rw-r--r-- | source/features/forked-to.tsx | 2 | ||||
-rw-r--r-- | source/features/hide-useless-comments.tsx | 2 | ||||
-rw-r--r-- | source/features/link-to-file-in-file-history.tsx | 3 | ||||
-rw-r--r-- | source/features/linkify-urls-in-code.tsx | 2 | ||||
-rw-r--r-- | source/features/minimize-upload-bar.tsx | 2 | ||||
-rw-r--r-- | source/features/pr-branch-auto-delete.tsx | 2 | ||||
-rw-r--r-- | source/features/revert-file.tsx | 11 | ||||
-rw-r--r-- | source/features/show-names.tsx | 2 | ||||
-rw-r--r-- | source/features/sticky-discussion-sidebar.tsx | 2 | ||||
-rw-r--r-- | source/features/submit-review-as-single-comment.tsx | 2 | ||||
-rw-r--r-- | source/features/tags-dropdown.tsx | 2 | ||||
-rw-r--r-- | source/features/view-markdown-source.tsx | 4 |
13 files changed, 19 insertions, 21 deletions
diff --git a/source/features/follow-file-renames.tsx b/source/features/follow-file-renames.tsx index 0657f386..0f50ccf3 100644 --- a/source/features/follow-file-renames.tsx +++ b/source/features/follow-file-renames.tsx @@ -17,10 +17,10 @@ async function findRename( ): Promise<File[]> { // API v4 doesn't support it: https://github.community/t5/GitHub-API-Development-and/What-is-the-corresponding-object-in-GraphQL-API-v4-for-patch/m-p/14502?collapse_discussion=true&filter=location&location=board:api&q=files%20changed%20commit&search_type=thread const {files} = await api.v3(`repos/${user}/${repo}/commits/${lastCommitOnPage}`); - return files as Promise<File[]>; + return files as File[]; } -async function init(): Promise<false | void> { +function init(): false | void { const disabledPagination = select.all('.paginate-container [disabled], .paginate-container .disabled'); if (disabledPagination.length === 0) { diff --git a/source/features/forked-to.tsx b/source/features/forked-to.tsx index 867a9467..33e44e29 100644 --- a/source/features/forked-to.tsx +++ b/source/features/forked-to.tsx @@ -17,7 +17,7 @@ async function save(forks: string[]): Promise<void> { return cache.set(getCacheKey(), forks, 10); } -async function saveAllForks(): Promise<void> { +function saveAllForks(): void { const forks = select .all('details-dialog[src*="/fork"] .octicon-repo-forked') .map(({nextSibling}) => nextSibling!.textContent!.trim()); diff --git a/source/features/hide-useless-comments.tsx b/source/features/hide-useless-comments.tsx index 98accf05..df40a45f 100644 --- a/source/features/hide-useless-comments.tsx +++ b/source/features/hide-useless-comments.tsx @@ -17,7 +17,7 @@ function init(): void { } // Ensure that they're not by VIPs (owner, collaborators, etc) - const comment = commentText.closest('.js-timeline-item') as HTMLElement; + const comment = commentText.closest<HTMLElement>('.js-timeline-item')!; if (select.exists('.timeline-comment-label', comment)) { continue; } diff --git a/source/features/link-to-file-in-file-history.tsx b/source/features/link-to-file-in-file-history.tsx index 69591b1d..e754a40d 100644 --- a/source/features/link-to-file-in-file-history.tsx +++ b/source/features/link-to-file-in-file-history.tsx @@ -25,8 +25,7 @@ function init(): void | false { </a> ); - // TODO: drop `as` after https://github.com/Microsoft/TSJS-lib-generator/pull/697 - (rootLink.closest('.commit-links-cell') as HTMLElement).style.width = 'auto'; + rootLink.closest<HTMLElement>('.commit-links-cell')!.style.width = 'auto'; groupSiblings(rootLink); } diff --git a/source/features/linkify-urls-in-code.tsx b/source/features/linkify-urls-in-code.tsx index 066bfef3..9e9ca6a1 100644 --- a/source/features/linkify-urls-in-code.tsx +++ b/source/features/linkify-urls-in-code.tsx @@ -12,7 +12,7 @@ export function linkifyIssuesInDom(element: Element): void { } // Enable native issue title fetch - for (const link of (linkified.children as HTMLCollectionOf<HTMLAnchorElement>)) { + for (const link of linkified.children as HTMLCollectionOf<HTMLAnchorElement>) { const issue = link.href.split('/').pop(); link.setAttribute('class', 'issue-link js-issue-link tooltipped tooltipped-ne'); link.setAttribute('data-error-text', 'Failed to load issue title'); diff --git a/source/features/minimize-upload-bar.tsx b/source/features/minimize-upload-bar.tsx index a325388d..db0d3ceb 100644 --- a/source/features/minimize-upload-bar.tsx +++ b/source/features/minimize-upload-bar.tsx @@ -5,7 +5,7 @@ import delegate, {DelegateEvent} from 'delegate-it'; import features from '../libs/features'; import * as icons from '../libs/icons'; -async function addButton(): Promise<void> { +function addButton(): void { for (const toolbarButton of select.all('md-ref')) { toolbarButton.after( <button type="button" className="toolbar-item tooltipped tooltipped-n rgh-upload-btn" aria-label="Attach files"> diff --git a/source/features/pr-branch-auto-delete.tsx b/source/features/pr-branch-auto-delete.tsx index 9282b6ba..acfd28fa 100644 --- a/source/features/pr-branch-auto-delete.tsx +++ b/source/features/pr-branch-auto-delete.tsx @@ -4,7 +4,7 @@ import features from '../libs/features'; import observeEl from '../libs/simplified-element-observer'; function init(): void { - const [subscription] = delegate('#discussion_bucket', '.js-merge-commit-button', 'click', async () => { + const [subscription] = delegate('#discussion_bucket', '.js-merge-commit-button', 'click', () => { subscription.destroy(); observeEl('.discussion-timeline-actions', (_, observer) => { diff --git a/source/features/revert-file.tsx b/source/features/revert-file.tsx index 0c17ca88..347fad5c 100644 --- a/source/features/revert-file.tsx +++ b/source/features/revert-file.tsx @@ -30,7 +30,7 @@ const getBaseRef = onetime(async (): Promise<string> => { }); async function getFile(menuItem: Element): Promise<{isTruncated: boolean; text: string}> { - const filePath = (menuItem.closest('[data-path]') as HTMLElement).dataset.path!; + const filePath = menuItem.closest<HTMLElement>('[data-path]')!.dataset.path!; const {repository} = await api.v4(` repository(${getRepoGQL()}) { file: object(expression: "${await getBaseRef()}:${filePath}") { @@ -45,8 +45,6 @@ async function getFile(menuItem: Element): Promise<{isTruncated: boolean; text: } async function deleteFile(menuItem: Element): Promise<void> { - // The `a` selector skips the broken Delete link on some pages. GitHub's bug. - // TODO: where? What happens when it's not found? menuItem.textContent = 'Deleting…'; const deleteFileLink = select<HTMLAnchorElement>('a[aria-label^="Delete this"]', menuItem.parentElement!)!; @@ -77,7 +75,8 @@ async function commitFileContent(menuItem: Element, content: string): Promise<vo async function handleRevertFileClick(event: React.MouseEvent<HTMLButtonElement>): Promise<void> { const menuItem = event.currentTarget; // Allow only one click - menuItem.removeEventListener('click', handleRevertFileClick as any); // TODO: change JSX event types to be plain browser events + // TODO: change JSX event types to be plain browser events + menuItem.removeEventListener('click', handleRevertFileClick as any); menuItem.textContent = 'Reverting…'; event.preventDefault(); event.stopPropagation(); @@ -88,7 +87,7 @@ async function handleRevertFileClick(event: React.MouseEvent<HTMLButtonElement>) if (!file) { // The file was created by this PR. Revert === Delete. // If there was a way to tell if a file was created by the PR, we could skip `getFile` - // TODO: find this info on the page + // TODO: find this info on the page ("was this file created by this PR?") await deleteFile(menuItem); return; } @@ -108,7 +107,7 @@ async function handleRevertFileClick(event: React.MouseEvent<HTMLButtonElement>) } } -async function handleMenuOpening(event: DelegateEvent): Promise<void> { +function handleMenuOpening(event: DelegateEvent): void { const dropdown = event.delegateTarget.nextElementSibling!; const editFile = select<HTMLAnchorElement>('[aria-label^="Change this"]', dropdown); diff --git a/source/features/show-names.tsx b/source/features/show-names.tsx index 43fcfe5f..9363e991 100644 --- a/source/features/show-names.tsx +++ b/source/features/show-names.tsx @@ -72,7 +72,7 @@ features.add({ features.isDashboard ], load: features.onDomReady, - init: async () => onNewsfeedLoad(init) + init: () => onNewsfeedLoad(init) }); features.add({ diff --git a/source/features/sticky-discussion-sidebar.tsx b/source/features/sticky-discussion-sidebar.tsx index edbc729b..82e2938a 100644 --- a/source/features/sticky-discussion-sidebar.tsx +++ b/source/features/sticky-discussion-sidebar.tsx @@ -4,7 +4,7 @@ import debounce from 'debounce-fn'; import features from '../libs/features'; function updateStickiness(): void { - const sidebar = select<HTMLElement>('#partial-discussion-sidebar')!; + const sidebar = select('#partial-discussion-sidebar')!; const sidebarHeight = sidebar.offsetHeight + 60; // 60 matches sticky header's height sidebar.classList.toggle('rgh-sticky-sidebar', sidebarHeight < window.innerHeight); } diff --git a/source/features/submit-review-as-single-comment.tsx b/source/features/submit-review-as-single-comment.tsx index 74b0cd45..32238e28 100644 --- a/source/features/submit-review-as-single-comment.tsx +++ b/source/features/submit-review-as-single-comment.tsx @@ -64,7 +64,7 @@ async function handleSubmitSingle(event: DelegateEvent): Promise<void> { // Use nearby comment box const comment = await getNewCommentField(commentContainer, lineBeingCommentedOn); const submitButton = select<HTMLButtonElement>('[name="single_comment"]', comment.form!)!; - const commentForm = comment.closest('.inline-comment-form-container') as HTMLElement; + const commentForm = comment.closest<HTMLElement>('.inline-comment-form-container')!; // Copy comment to new comment box insertText(comment.form!.elements['comment[body]'] as HTMLTextAreaElement, commentText); diff --git a/source/features/tags-dropdown.tsx b/source/features/tags-dropdown.tsx index 6e61e306..e151c968 100644 --- a/source/features/tags-dropdown.tsx +++ b/source/features/tags-dropdown.tsx @@ -5,7 +5,7 @@ import features from '../libs/features'; import {getRepoURL} from '../libs/utils'; import {octoface} from '../libs/icons'; -async function init(): Promise<false | void> { +function init(): false | void { if (select.exists('.blankslate')) { return false; } diff --git a/source/features/view-markdown-source.tsx b/source/features/view-markdown-source.tsx index 79501013..39a0d407 100644 --- a/source/features/view-markdown-source.tsx +++ b/source/features/view-markdown-source.tsx @@ -39,7 +39,7 @@ async function showSource(): Promise<void> { sourceButton.disabled = true; const source = btnBodyMap.get(sourceButton) || fetchSource(); - const rendered = btnBodyMap.get(renderedButton) as Element || select('.blob.instapaper_body')!; + const rendered = await btnBodyMap.get(renderedButton) || select('.blob.instapaper_body')!; btnBodyMap.set(sourceButton, source); btnBodyMap.set(renderedButton, rendered); @@ -61,7 +61,7 @@ async function showRendered(): Promise<void> { renderedButton.disabled = true; - (await btnBodyMap.get(sourceButton))!.replaceWith(btnBodyMap.get(renderedButton) as Element); + (await btnBodyMap.get(sourceButton))!.replaceWith(await btnBodyMap.get(renderedButton)!); renderedButton.disabled = false; |