add strict nulls for contrib/extensions (#11916)

This commit is contained in:
Anthony Dresser
2020-08-21 17:17:59 -07:00
committed by GitHub
parent f4f4271115
commit 9d680be37a
20 changed files with 125 additions and 112 deletions

View File

@@ -4,10 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import { append, $ } from 'vs/base/browser/dom';
import { IInsightTypeContrib } from 'sql/workbench/contrib/dashboard/browser/widgets/insights/interfaces';
import { IDashboardTabContrib } from 'sql/workbench/contrib/dashboard/browser/core/dashboardTab.contribution';
import { localize } from 'vs/nls';
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { IDashboardTabContrib, IExtensionContributions, IInsightTypeContrib } from 'sql/platform/extensions/common/extensions';
class ContributionReader {
constructor(private manifest: IExtensionManifest) { }
@@ -15,7 +14,7 @@ class ContributionReader {
public dashboardInsights(): IInsightTypeContrib[] {
let contributes = this.manifest.contributes;
if (contributes) {
let insights: IInsightTypeContrib | IInsightTypeContrib[] = contributes['dashboard.insights'];
let insights = (contributes as IExtensionContributions)['dashboard.insights'];
if (insights) {
if (!Array.isArray(insights)) {
return [insights];
@@ -23,13 +22,13 @@ class ContributionReader {
return insights;
}
}
return undefined;
return [];
}
public dashboardTabs(): IDashboardTabContrib[] {
let contributes = this.manifest.contributes;
if (contributes) {
let tabs: IDashboardTabContrib | IDashboardTabContrib[] = contributes['dashboard.tabs'];
let tabs = (contributes as IExtensionContributions)['dashboard.tabs'];
if (tabs) {
if (!Array.isArray(tabs)) {
return [tabs];
@@ -37,7 +36,7 @@ class ContributionReader {
return tabs;
}
}
return undefined;
return [];
}
}
@@ -56,17 +55,17 @@ function renderDashboardTabs(onDetailsToggle: Function, contributionReader: Cont
}
const details = $('details', { open: true, ontoggle: onDetailsToggle },
$('summary', null, localize('tabs', "Dashboard Tabs ({0})", tabs.length)),
$('table', null,
$('tr', null,
$('th', null, localize('tabId', "Id")),
$('th', null, localize('tabTitle', "Title")),
$('th', null, localize('tabDescription', "Description"))
$('summary', undefined, localize('tabs', "Dashboard Tabs ({0})", tabs.length)),
$('table', undefined,
$('tr', undefined,
$('th', undefined, localize('tabId', "Id")),
$('th', undefined, localize('tabTitle', "Title")),
$('th', undefined, localize('tabDescription', "Description"))
),
...tabs.map(tab => $('tr', null,
$('td', null, $('code', null, tab.id)),
$('td', null, tab.title ? tab.title : tab.id),
$('td', null, tab.description),
...tabs.map(tab => $('tr', undefined,
$('td', undefined, $('code', undefined, tab.id)),
$('td', undefined, tab.title ? tab.title : tab.id),
$('td', undefined, tab.description ?? ''),
))
)
);
@@ -83,17 +82,17 @@ function renderDashboardInsights(onDetailsToggle: Function, contributionReader:
}
const details = $('details', { open: true, ontoggle: onDetailsToggle },
$('summary', null, localize('insights', "Dashboard Insights ({0})", insights.length)),
$('table', null,
$('tr', null,
$('th', null, localize('insightId', "Id")),
$('th', null, localize('name', "Name")),
$('th', null, localize('insight condition', "When"))
$('summary', undefined, localize('insights', "Dashboard Insights ({0})", insights.length)),
$('table', undefined,
$('tr', undefined,
$('th', undefined, localize('insightId', "Id")),
$('th', undefined, localize('name', "Name")),
$('th', undefined, localize('insight condition', "When"))
),
...insights.map(insight => $('tr', null,
$('td', null, $('code', null, insight.id)),
$('td', null, insight.contrib.name ? insight.contrib.name : insight.id),
$('td', null, insight.contrib.when),
...insights.map(insight => $('tr', undefined,
$('td', undefined, $('code', undefined, insight.id)),
$('td', undefined, insight.contrib.name ? insight.contrib.name : insight.id),
$('td', undefined, insight.contrib.when ?? ''),
))
)
);