diff options
author | 2019-04-17 08:42:27 -0400 | |
---|---|---|
committer | 2019-04-17 20:42:27 +0800 | |
commit | 7b3b275ad9a1b1409c56310c0b8ab286bef1f75f (patch) | |
tree | 90de3c1682fbad57234cffa2e71f51baab7680c4 /source/features/linkify-urls-in-code.tsx | |
parent | 438f98c7d7760b5e24ebf0bd9634d0c447226196 (diff) | |
download | refined-github-7b3b275ad9a1b1409c56310c0b8ab286bef1f75f.tar.gz refined-github-7b3b275ad9a1b1409c56310c0b8ab286bef1f75f.tar.zst refined-github-7b3b275ad9a1b1409c56310c0b8ab286bef1f75f.zip |
Enable strict-mode for TypeScript (#1783)
Co-authored-by: Federico Brigante <github@bfred.it>
Diffstat (limited to 'source/features/linkify-urls-in-code.tsx')
-rw-r--r-- | source/features/linkify-urls-in-code.tsx | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source/features/linkify-urls-in-code.tsx b/source/features/linkify-urls-in-code.tsx index c46ba764..60ffe510 100644 --- a/source/features/linkify-urls-in-code.tsx +++ b/source/features/linkify-urls-in-code.tsx @@ -23,17 +23,20 @@ const options = { } }; -export const editTextNodes = (fn, el) => { +export const editTextNodes = ( + fn: typeof linkifyIssues | typeof linkifyUrls, + el: HTMLElement +) => { for (const textNode of getTextNodes(el)) { - if (fn === linkifyUrls && textNode.textContent.length < 11) { // Shortest url: http://j.mp + if (fn === linkifyUrls && textNode.textContent!.length < 11) { // Shortest url: http://j.mp continue; } - const linkified = fn(textNode.textContent, options); + const linkified = fn(textNode.textContent!, options); if (linkified.children.length > 0) { // Children are <a> if (fn === linkifyIssues) { // Enable native issue title fetch - for (const link of linkified.children) { + 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'); @@ -48,7 +51,7 @@ export const editTextNodes = (fn, el) => { } }; -function init() { +function init(): false | void { const wrappers = select.all(` .blob-wrapper:not(.${linkifiedURLClass}), .comment-body:not(.${linkifiedURLClass}) |