Skip to content

Commit 6a288b7

Browse files
committed
Enable strictNullChecks
1 parent 37208fe commit 6a288b7

File tree

107 files changed

+697
-661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+697
-661
lines changed

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"strictBindCallApply": true,
4141
"strictBuiltinIteratorReturn": true,
4242
"strictFunctionTypes": true,
43-
"strictNullChecks": false,
43+
"strictNullChecks": true,
4444
"stripInternal": true,
4545
"verbatimModuleSyntax": true,
4646
"types": [

web_src/js/bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function showGlobalErrorMessage(msg: string, msgType: Intent = 'error') {
3535
const msgCount = Number(msgDiv.getAttribute(`data-global-error-msg-count`)) + 1;
3636
msgDiv.setAttribute(`data-global-error-msg-compact`, msgCompact);
3737
msgDiv.setAttribute(`data-global-error-msg-count`, msgCount.toString());
38-
msgDiv.querySelector('.ui.message').textContent = msg + (msgCount > 1 ? ` (${msgCount})` : '');
38+
msgDiv.querySelector('.ui.message')!.textContent = msg + (msgCount > 1 ? ` (${msgCount})` : '');
3939
msgContainer.prepend(msgDiv);
4040
}
4141

web_src/js/components/ActivityHeatmap.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {onMounted, shallowRef} from 'vue';
55
import type {Value as HeatmapValue, Locale as HeatmapLocale} from '@silverwind/vue3-calendar-heatmap';
66
77
defineProps<{
8-
values?: HeatmapValue[];
8+
values: HeatmapValue[];
99
locale: {
1010
textTotalContributions: string;
1111
heatMapLocale: Partial<HeatmapLocale>;
@@ -28,7 +28,7 @@ const endDate = shallowRef(new Date());
2828
2929
onMounted(() => {
3030
// work around issue with first legend color being rendered twice and legend cut off
31-
const legend = document.querySelector<HTMLElement>('.vch__external-legend-wrapper');
31+
const legend = document.querySelector<HTMLElement>('.vch__external-legend-wrapper')!;
3232
legend.setAttribute('viewBox', '12 0 80 10');
3333
legend.style.marginRight = '-12px';
3434
});

web_src/js/components/ContextPopup.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ const props = defineProps<{
1111
}>();
1212
1313
const loading = shallowRef(false);
14-
const issue = shallowRef<Issue>(null);
14+
const issue = shallowRef<Issue | null>(null);
1515
const renderedLabels = shallowRef('');
1616
const errorMessage = shallowRef('');
1717
1818
const createdAt = computed(() => {
19+
if (!issue?.value) return '';
1920
return new Date(issue.value.created_at).toLocaleDateString(undefined, {year: 'numeric', month: 'short', day: 'numeric'});
2021
});
2122
2223
const body = computed(() => {
24+
if (!issue?.value) return '';
2325
const body = issue.value.body.replace(/\n+/g, ' ');
2426
return body.length > 85 ? `${body.substring(0, 85)}…` : body;
2527
});

web_src/js/components/DashboardRepoList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ export default defineComponent({
110110
},
111111
112112
mounted() {
113-
const el = document.querySelector('#dashboard-repo-list');
113+
const el = document.querySelector('#dashboard-repo-list')!;
114114
this.changeReposFilter(this.reposFilter);
115-
fomanticQuery(el.querySelector('.ui.dropdown')).dropdown();
115+
fomanticQuery(el.querySelector('.ui.dropdown')!).dropdown();
116116
117117
this.textArchivedFilterTitles = {
118118
'archived': this.textShowOnlyArchived,

web_src/js/components/DiffCommitSelector.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type CommitListResult = {
2323
export default defineComponent({
2424
components: {SvgIcon},
2525
data: () => {
26-
const el = document.querySelector('#diff-commit-select');
26+
const el = document.querySelector('#diff-commit-select')!;
2727
return {
2828
menuVisible: false,
2929
isLoading: false,
@@ -35,7 +35,7 @@ export default defineComponent({
3535
mergeBase: el.getAttribute('data-merge-base'),
3636
commits: [] as Array<Commit>,
3737
hoverActivated: false,
38-
lastReviewCommitSha: '',
38+
lastReviewCommitSha: '' as string | null,
3939
uniqueIdMenu: generateElemId('diff-commit-selector-menu-'),
4040
uniqueIdShowAll: generateElemId('diff-commit-selector-show-all-'),
4141
};
@@ -165,7 +165,7 @@ export default defineComponent({
165165
},
166166
/** Called when user clicks on since last review */
167167
changesSinceLastReviewClick() {
168-
window.location.assign(`${this.issueLink}/files/${this.lastReviewCommitSha}..${this.commits.at(-1).id}${this.queryParams}`);
168+
window.location.assign(`${this.issueLink}/files/${this.lastReviewCommitSha}..${this.commits.at(-1)!.id}${this.queryParams}`);
169169
},
170170
/** Clicking on a single commit opens this specific commit */
171171
commitClicked(commitId: string, newWindow = false) {
@@ -193,7 +193,7 @@ export default defineComponent({
193193
// find all selected commits and generate a link
194194
const firstSelected = this.commits.findIndex((x) => x.selected);
195195
const lastSelected = this.commits.findLastIndex((x) => x.selected);
196-
let beforeCommitID: string;
196+
let beforeCommitID: string | null = null;
197197
if (firstSelected === 0) {
198198
beforeCommitID = this.mergeBase;
199199
} else {
@@ -204,7 +204,7 @@ export default defineComponent({
204204
if (firstSelected === lastSelected) {
205205
// if the start and end are the same, we show this single commit
206206
window.location.assign(`${this.issueLink}/commits/${afterCommitID}${this.queryParams}`);
207-
} else if (beforeCommitID === this.mergeBase && afterCommitID === this.commits.at(-1).id) {
207+
} else if (beforeCommitID === this.mergeBase && afterCommitID === this.commits.at(-1)!.id) {
208208
// if the first commit is selected and the last commit is selected, we show all commits
209209
window.location.assign(`${this.issueLink}/files${this.queryParams}`);
210210
} else {

web_src/js/components/DiffFileTree.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ const store = diffTreeStore();
1212
onMounted(() => {
1313
// Default to true if unset
1414
store.fileTreeIsVisible = localStorage.getItem(LOCAL_STORAGE_KEY) !== 'false';
15-
document.querySelector('.diff-toggle-file-tree-button').addEventListener('click', toggleVisibility);
15+
document.querySelector('.diff-toggle-file-tree-button')!.addEventListener('click', toggleVisibility);
1616
1717
hashChangeListener();
1818
window.addEventListener('hashchange', hashChangeListener);
1919
});
2020
2121
onUnmounted(() => {
22-
document.querySelector('.diff-toggle-file-tree-button').removeEventListener('click', toggleVisibility);
22+
document.querySelector('.diff-toggle-file-tree-button')!.removeEventListener('click', toggleVisibility);
2323
window.removeEventListener('hashchange', hashChangeListener);
2424
});
2525
@@ -33,7 +33,7 @@ function expandSelectedFile() {
3333
if (store.selectedItem) {
3434
const box = document.querySelector(store.selectedItem);
3535
const folded = box?.getAttribute('data-folded') === 'true';
36-
if (folded) setFileFolding(box, box.querySelector('.fold-file'), false);
36+
if (folded) setFileFolding(box, box.querySelector('.fold-file')!, false);
3737
}
3838
}
3939
@@ -48,10 +48,10 @@ function updateVisibility(visible: boolean) {
4848
}
4949
5050
function updateState(visible: boolean) {
51-
const btn = document.querySelector('.diff-toggle-file-tree-button');
51+
const btn = document.querySelector('.diff-toggle-file-tree-button')!;
5252
const [toShow, toHide] = btn.querySelectorAll('.icon');
53-
const tree = document.querySelector('#diff-file-tree');
54-
const newTooltip = btn.getAttribute(visible ? 'data-hide-text' : 'data-show-text');
53+
const tree = document.querySelector('#diff-file-tree')!;
54+
const newTooltip = btn.getAttribute(visible ? 'data-hide-text' : 'data-show-text')!;
5555
btn.setAttribute('data-tooltip-content', newTooltip);
5656
toggleElem(tree, visible);
5757
toggleElem(toShow, !visible);

web_src/js/components/RepoActionView.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export default defineComponent({
402402
}
403403
404404
// auto-scroll to the last log line of the last step
405-
let autoScrollJobStepElement: HTMLElement;
405+
let autoScrollJobStepElement: HTMLElement | undefined;
406406
for (let stepIndex = 0; stepIndex < this.currentJob.steps.length; stepIndex++) {
407407
if (!autoScrollStepIndexes.get(stepIndex)) continue;
408408
autoScrollJobStepElement = this.getJobStepLogsContainer(stepIndex);
@@ -468,7 +468,7 @@ export default defineComponent({
468468
}
469469
const logLine = this.elStepsContainer().querySelector(selectedLogStep);
470470
if (!logLine) return;
471-
logLine.querySelector<HTMLAnchorElement>('.line-num').click();
471+
logLine.querySelector<HTMLAnchorElement>('.line-num')!.click();
472472
},
473473
},
474474
});

web_src/js/components/RepoActivityTopAuthors.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const styleElement = useTemplateRef('styleElement');
4545
const altStyleElement = useTemplateRef('altStyleElement');
4646
4747
onMounted(() => {
48-
const refStyle = window.getComputedStyle(styleElement.value);
49-
const refAltStyle = window.getComputedStyle(altStyleElement.value);
48+
const refStyle = window.getComputedStyle(styleElement.value!);
49+
const refAltStyle = window.getComputedStyle(altStyleElement.value!);
5050
5151
colors.value = {
5252
barColor: refStyle.backgroundColor,

web_src/js/components/RepoBranchTagSelector.vue

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default defineComponent({
2323
elRoot: HTMLElement,
2424
},
2525
data() {
26-
const shouldShowTabBranches = this.elRoot.getAttribute('data-show-tab-branches') === 'true';
26+
const shouldShowTabBranches = this.elRoot!.getAttribute('data-show-tab-branches') === 'true';
2727
return {
2828
csrfToken: window.config.csrfToken,
2929
allItems: [] as ListItem[],
@@ -33,33 +33,33 @@ export default defineComponent({
3333
activeItemIndex: 0,
3434
tabLoadingStates: {} as TabLoadingStates,
3535
36-
textReleaseCompare: this.elRoot.getAttribute('data-text-release-compare'),
37-
textBranches: this.elRoot.getAttribute('data-text-branches'),
38-
textTags: this.elRoot.getAttribute('data-text-tags'),
39-
textFilterBranch: this.elRoot.getAttribute('data-text-filter-branch'),
40-
textFilterTag: this.elRoot.getAttribute('data-text-filter-tag'),
41-
textDefaultBranchLabel: this.elRoot.getAttribute('data-text-default-branch-label'),
42-
textCreateTag: this.elRoot.getAttribute('data-text-create-tag'),
43-
textCreateBranch: this.elRoot.getAttribute('data-text-create-branch'),
44-
textCreateRefFrom: this.elRoot.getAttribute('data-text-create-ref-from'),
45-
textNoResults: this.elRoot.getAttribute('data-text-no-results'),
46-
textViewAllBranches: this.elRoot.getAttribute('data-text-view-all-branches'),
47-
textViewAllTags: this.elRoot.getAttribute('data-text-view-all-tags'),
36+
textReleaseCompare: this.elRoot!.getAttribute('data-text-release-compare')!,
37+
textBranches: this.elRoot!.getAttribute('data-text-branches')!,
38+
textTags: this.elRoot!.getAttribute('data-text-tags')!,
39+
textFilterBranch: this.elRoot!.getAttribute('data-text-filter-branch')!,
40+
textFilterTag: this.elRoot!.getAttribute('data-text-filter-tag')!,
41+
textDefaultBranchLabel: this.elRoot!.getAttribute('data-text-default-branch-label')!,
42+
textCreateTag: this.elRoot!.getAttribute('data-text-create-tag')!,
43+
textCreateBranch: this.elRoot!.getAttribute('data-text-create-branch')!,
44+
textCreateRefFrom: this.elRoot!.getAttribute('data-text-create-ref-from')!,
45+
textNoResults: this.elRoot!.getAttribute('data-text-no-results')!,
46+
textViewAllBranches: this.elRoot!.getAttribute('data-text-view-all-branches')!,
47+
textViewAllTags: this.elRoot!.getAttribute('data-text-view-all-tags')!,
4848
49-
currentRepoDefaultBranch: this.elRoot.getAttribute('data-current-repo-default-branch'),
50-
currentRepoLink: this.elRoot.getAttribute('data-current-repo-link'),
51-
currentTreePath: this.elRoot.getAttribute('data-current-tree-path'),
52-
currentRefType: this.elRoot.getAttribute('data-current-ref-type') as GitRefType,
53-
currentRefShortName: this.elRoot.getAttribute('data-current-ref-short-name'),
49+
currentRepoDefaultBranch: this.elRoot!.getAttribute('data-current-repo-default-branch')!,
50+
currentRepoLink: this.elRoot!.getAttribute('data-current-repo-link')!,
51+
currentTreePath: this.elRoot!.getAttribute('data-current-tree-path')!,
52+
currentRefType: this.elRoot!.getAttribute('data-current-ref-type')! as GitRefType,
53+
currentRefShortName: this.elRoot!.getAttribute('data-current-ref-short-name')!,
5454
55-
refLinkTemplate: this.elRoot.getAttribute('data-ref-link-template'),
56-
refFormActionTemplate: this.elRoot.getAttribute('data-ref-form-action-template'),
57-
dropdownFixedText: this.elRoot.getAttribute('data-dropdown-fixed-text'),
55+
refLinkTemplate: this.elRoot!.getAttribute('data-ref-link-template')!,
56+
refFormActionTemplate: this.elRoot!.getAttribute('data-ref-form-action-template')!,
57+
dropdownFixedText: this.elRoot!.getAttribute('data-dropdown-fixed-text')!,
5858
showTabBranches: shouldShowTabBranches,
59-
showTabTags: this.elRoot.getAttribute('data-show-tab-tags') === 'true',
60-
allowCreateNewRef: this.elRoot.getAttribute('data-allow-create-new-ref') === 'true',
61-
showViewAllRefsEntry: this.elRoot.getAttribute('data-show-view-all-refs-entry') === 'true',
62-
enableFeed: this.elRoot.getAttribute('data-enable-feed') === 'true',
59+
showTabTags: this.elRoot!.getAttribute('data-show-tab-tags') === 'true',
60+
allowCreateNewRef: this.elRoot!.getAttribute('data-allow-create-new-ref') === 'true',
61+
showViewAllRefsEntry: this.elRoot!.getAttribute('data-show-view-all-refs-entry') === 'true',
62+
enableFeed: this.elRoot!.getAttribute('data-enable-feed') === 'true',
6363
};
6464
},
6565
computed: {
@@ -92,7 +92,7 @@ export default defineComponent({
9292
}).length;
9393
},
9494
createNewRefFormActionUrl() {
95-
return `${this.currentRepoLink}/branches/_new/${this.currentRefType}/${pathEscapeSegments(this.currentRefShortName)}`;
95+
return `${this.currentRepoLink}/branches/_new/${this.currentRefType}/${pathEscapeSegments(this.currentRefShortName!)}`;
9696
},
9797
},
9898
watch: {

0 commit comments

Comments
 (0)