Add typings for strict null checks
This commit is contained in:
parent
148c2c41ad
commit
fb606be779
7 changed files with 31 additions and 25 deletions
|
@ -25,6 +25,7 @@
|
|||
"./vs/base/browser/ui/list/splice.ts",
|
||||
"./vs/base/browser/ui/octiconLabel/octiconLabel.mock.ts",
|
||||
"./vs/base/browser/ui/octiconLabel/octiconLabel.ts",
|
||||
"./vs/base/browser/ui/progressbar/progressbar.ts",
|
||||
"./vs/base/browser/ui/scrollbar/abstractScrollbar.ts",
|
||||
"./vs/base/browser/ui/scrollbar/horizontalScrollbar.ts",
|
||||
"./vs/base/browser/ui/scrollbar/scrollableElement.ts",
|
||||
|
@ -35,7 +36,6 @@
|
|||
"./vs/base/browser/ui/scrollbar/verticalScrollbar.ts",
|
||||
"./vs/base/browser/ui/tree/tree.ts",
|
||||
"./vs/base/browser/ui/widget.ts",
|
||||
"./vs/base/common/actions.ts",
|
||||
"./vs/base/common/amd.ts",
|
||||
"./vs/base/common/arrays.ts",
|
||||
"./vs/base/common/assert.ts",
|
||||
|
@ -76,6 +76,7 @@
|
|||
"./vs/base/common/normalization.ts",
|
||||
"./vs/base/common/numbers.ts",
|
||||
"./vs/base/common/objects.ts",
|
||||
"./vs/base/common/octicon.ts",
|
||||
"./vs/base/common/paging.ts",
|
||||
"./vs/base/common/parsers.ts",
|
||||
"./vs/base/common/paths.ts",
|
||||
|
@ -100,6 +101,7 @@
|
|||
"./vs/base/node/id.ts",
|
||||
"./vs/base/node/paths.ts",
|
||||
"./vs/base/node/ports.ts",
|
||||
"./vs/base/node/request.ts",
|
||||
"./vs/base/parts/contextmenu/common/contextmenu.ts",
|
||||
"./vs/base/parts/contextmenu/electron-main/contextmenu.ts",
|
||||
"./vs/base/parts/quickopen/common/quickOpen.ts",
|
||||
|
@ -316,6 +318,7 @@
|
|||
"./vs/editor/contrib/message/messageController.ts",
|
||||
"./vs/editor/contrib/parameterHints/provideSignatureHelp.ts",
|
||||
"./vs/editor/contrib/quickOpen/quickOpen.ts",
|
||||
"./vs/editor/contrib/suggest/suggest.ts",
|
||||
"./vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode.ts",
|
||||
"./vs/editor/contrib/wordHighlighter/wordHighlighter.ts",
|
||||
"./vs/editor/contrib/wordOperations/wordOperations.ts",
|
||||
|
@ -403,6 +406,7 @@
|
|||
"./vs/platform/quickOpen/common/quickOpen.ts",
|
||||
"./vs/platform/quickinput/common/quickInput.ts",
|
||||
"./vs/platform/registry/common/platform.ts",
|
||||
"./vs/platform/request/node/request.ts",
|
||||
"./vs/platform/search/common/search.ts",
|
||||
"./vs/platform/state/common/state.ts",
|
||||
"./vs/platform/statusbar/common/statusbar.ts",
|
||||
|
@ -424,6 +428,7 @@
|
|||
"./vs/platform/workspaces/common/workspaces.ts",
|
||||
"./vs/platform/workspaces/node/workspaces.ts",
|
||||
"./vs/workbench/api/shared/tasks.ts",
|
||||
"./vs/workbench/browser/part.ts",
|
||||
"./vs/workbench/browser/parts/quickinput/quickInputUtils.ts",
|
||||
"./vs/workbench/browser/parts/statusbar/statusbar.ts",
|
||||
"./vs/workbench/common/activity.ts",
|
||||
|
@ -461,6 +466,7 @@
|
|||
"./vs/workbench/parts/scm/common/scm.ts",
|
||||
"./vs/workbench/parts/scm/electron-browser/scmUtil.ts",
|
||||
"./vs/workbench/parts/search/common/constants.ts",
|
||||
"./vs/workbench/parts/surveys/electron-browser/nps.contribution.ts",
|
||||
"./vs/workbench/parts/tasks/common/taskTemplates.ts",
|
||||
"./vs/workbench/parts/terminal/browser/terminalWidgetManager.ts",
|
||||
"./vs/workbench/parts/terminal/common/terminal.ts",
|
||||
|
|
|
@ -37,8 +37,8 @@ export class ProgressBar extends Disposable {
|
|||
private workedVal: number;
|
||||
private element: HTMLElement;
|
||||
private bit: HTMLElement;
|
||||
private totalWork: number;
|
||||
private progressBarBackground: Color;
|
||||
private totalWork: number | undefined;
|
||||
private progressBarBackground: Color | undefined;
|
||||
private showDelayedScheduler: RunOnceScheduler;
|
||||
|
||||
constructor(container: HTMLElement, options?: IProgressBarOptions) {
|
||||
|
@ -146,7 +146,7 @@ export class ProgressBar extends Disposable {
|
|||
* Finds out if this progress bar is configured with total work
|
||||
*/
|
||||
hasTotal(): boolean {
|
||||
return !isNaN(this.totalWork);
|
||||
return !isNaN(this.totalWork as number);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,10 +172,10 @@ export class ProgressBar extends Disposable {
|
|||
}
|
||||
|
||||
private doSetWorked(value: number): ProgressBar {
|
||||
assert.ok(!isNaN(this.totalWork), 'Total work not set');
|
||||
assert.ok(!isNaN(this.totalWork as number), 'Total work not set');
|
||||
|
||||
this.workedVal = value;
|
||||
this.workedVal = Math.min(this.totalWork, this.workedVal);
|
||||
this.workedVal = Math.min(this.totalWork as number, this.workedVal);
|
||||
|
||||
if (hasClass(this.element, css_infinite)) {
|
||||
removeClass(this.element, css_infinite);
|
||||
|
@ -193,7 +193,7 @@ export class ProgressBar extends Disposable {
|
|||
addClass(this.element, css_discrete);
|
||||
}
|
||||
|
||||
this.bit.style.width = 100 * (this.workedVal / this.totalWork) + '%';
|
||||
this.bit.style.width = 100 * (this.workedVal / (this.totalWork as number)) + '%';
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ function doParseOcticons(text: string, firstOcticonIndex: number): IParsedOctico
|
|||
return { text: textWithoutOcticons, octiconOffsets };
|
||||
}
|
||||
|
||||
export function matchesFuzzyOcticonAware(query: string, target: IParsedOcticons, enableSeparateSubstringMatching = false): IMatch[] {
|
||||
export function matchesFuzzyOcticonAware(query: string, target: IParsedOcticons, enableSeparateSubstringMatching = false): IMatch[] | null {
|
||||
const { text, octiconOffsets } = target;
|
||||
|
||||
// Return early if there are no octicon markers in the word to match against
|
||||
|
|
|
@ -49,7 +49,7 @@ export interface IRequestFunction {
|
|||
}
|
||||
|
||||
async function getNodeRequest(options: IRequestOptions): Promise<IRawRequestFunction> {
|
||||
const endpoint = parseUrl(options.url);
|
||||
const endpoint = parseUrl(options.url!);
|
||||
const module = endpoint.protocol === 'https:' ? await import('https') : await import('http');
|
||||
return module.request;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ export function request(options: IRequestOptions, token: CancellationToken): Pro
|
|||
return rawRequestPromise.then(rawRequest => {
|
||||
|
||||
return new Promise<IRequestContext>((c, e) => {
|
||||
const endpoint = parseUrl(options.url);
|
||||
const endpoint = parseUrl(options.url!);
|
||||
|
||||
const opts: https.RequestOptions = {
|
||||
hostname: endpoint.hostname,
|
||||
|
@ -82,8 +82,8 @@ export function request(options: IRequestOptions, token: CancellationToken): Pro
|
|||
}
|
||||
|
||||
req = rawRequest(opts, (res: http.ClientResponse) => {
|
||||
const followRedirects = isNumber(options.followRedirects) ? options.followRedirects : 3;
|
||||
if (res.statusCode >= 300 && res.statusCode < 400 && followRedirects > 0 && res.headers['location']) {
|
||||
const followRedirects: number = isNumber(options.followRedirects) ? options.followRedirects : 3;
|
||||
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && followRedirects > 0 && res.headers['location']) {
|
||||
request(assign({}, options, {
|
||||
url: res.headers['location'],
|
||||
followRedirects: followRedirects - 1
|
||||
|
@ -125,7 +125,7 @@ export function request(options: IRequestOptions, token: CancellationToken): Pro
|
|||
}
|
||||
|
||||
function isSuccess(context: IRequestContext): boolean {
|
||||
return (context.res.statusCode >= 200 && context.res.statusCode < 300) || context.res.statusCode === 1223;
|
||||
return (context.res.statusCode && context.res.statusCode >= 200 && context.res.statusCode < 300) || context.res.statusCode === 1223;
|
||||
}
|
||||
|
||||
function hasNoContent(context: IRequestContext): boolean {
|
||||
|
@ -136,13 +136,13 @@ export function download(filePath: string, context: IRequestContext): Promise<vo
|
|||
return new Promise<void>((c, e) => {
|
||||
const out = createWriteStream(filePath);
|
||||
|
||||
out.once('finish', () => c(null));
|
||||
out.once('finish', () => c(void 0));
|
||||
context.stream.once('error', e);
|
||||
context.stream.pipe(out);
|
||||
});
|
||||
}
|
||||
|
||||
export function asText(context: IRequestContext): Promise<string> {
|
||||
export function asText(context: IRequestContext): Promise<string | null> {
|
||||
return new Promise((c, e) => {
|
||||
if (!isSuccess(context)) {
|
||||
return e('Server returned ' + context.res.statusCode);
|
||||
|
@ -159,7 +159,7 @@ export function asText(context: IRequestContext): Promise<string> {
|
|||
});
|
||||
}
|
||||
|
||||
export function asJson<T>(context: IRequestContext): Promise<T> {
|
||||
export function asJson<T>(context: IRequestContext): Promise<T | null> {
|
||||
return new Promise((c, e) => {
|
||||
if (!isSuccess(context)) {
|
||||
return e('Server returned ' + context.res.statusCode);
|
||||
|
|
|
@ -81,7 +81,7 @@ export function provideSuggestionItems(
|
|||
// for each support in the group ask for suggestions
|
||||
return Promise.all(supports.map(support => {
|
||||
|
||||
if (!isFalsyOrEmpty(onlyFrom) && onlyFrom.indexOf(support) < 0) {
|
||||
if (!isFalsyOrEmpty(onlyFrom) && onlyFrom!.indexOf(support) < 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ export interface IPartOptions {
|
|||
*/
|
||||
export abstract class Part extends Component {
|
||||
private parent: HTMLElement;
|
||||
private titleArea: HTMLElement;
|
||||
private contentArea: HTMLElement;
|
||||
private titleArea: HTMLElement | null;
|
||||
private contentArea: HTMLElement | null;
|
||||
private partLayout: PartLayout;
|
||||
|
||||
constructor(
|
||||
|
@ -67,28 +67,28 @@ export abstract class Part extends Component {
|
|||
/**
|
||||
* Subclasses override to provide a title area implementation.
|
||||
*/
|
||||
protected createTitleArea(parent: HTMLElement): HTMLElement {
|
||||
protected createTitleArea(parent: HTMLElement): HTMLElement | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title area container.
|
||||
*/
|
||||
protected getTitleArea(): HTMLElement {
|
||||
protected getTitleArea(): HTMLElement | null {
|
||||
return this.titleArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses override to provide a content area implementation.
|
||||
*/
|
||||
protected createContentArea(parent: HTMLElement): HTMLElement {
|
||||
protected createContentArea(parent: HTMLElement): HTMLElement | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content area container.
|
||||
*/
|
||||
protected getContentArea(): HTMLElement {
|
||||
protected getContentArea(): HTMLElement | null {
|
||||
return this.contentArea;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ export class PartLayout {
|
|||
|
||||
private static readonly TITLE_HEIGHT = 35;
|
||||
|
||||
constructor(container: HTMLElement, private options: IPartOptions, titleArea: HTMLElement, private contentArea: HTMLElement) { }
|
||||
constructor(container: HTMLElement, private options: IPartOptions, titleArea: HTMLElement | null, private contentArea: HTMLElement | null) { }
|
||||
|
||||
layout(dimension: Dimension): Dimension[] {
|
||||
const { width, height } = dimension;
|
||||
|
|
|
@ -39,7 +39,7 @@ class NPSContribution implements IWorkbenchContribution {
|
|||
return;
|
||||
}
|
||||
|
||||
const sessionCount = storageService.getInteger(SESSION_COUNT_KEY, StorageScope.GLOBAL, 0) + 1;
|
||||
const sessionCount = (storageService.getInteger(SESSION_COUNT_KEY, StorageScope.GLOBAL, 0) || 0) + 1;
|
||||
storageService.store(LAST_SESSION_DATE_KEY, date, StorageScope.GLOBAL);
|
||||
storageService.store(SESSION_COUNT_KEY, sessionCount, StorageScope.GLOBAL);
|
||||
|
||||
|
|
Loading…
Reference in a new issue