diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json index f0c3958065f..b8c84e0ec3e 100644 --- a/src/tsconfig.strictNullChecks.json +++ b/src/tsconfig.strictNullChecks.json @@ -7,11 +7,26 @@ "include": [ "./typings", "./vs/base/common/charCode.ts", + "./vs/base/common/color.ts", + "./vs/base/common/comparers.ts", + "./vs/base/common/date.ts", + "./vs/base/common/decorators.ts", + "./vs/base/common/functional.ts", + "./vs/base/common/idGenerator.ts", "./vs/base/common/iterator.ts", - "./vs/base/common/strings.ts", + "./vs/base/common/lifecycle.ts", + "./vs/base/common/network.ts", + "./vs/base/common/numbers.ts", + "./vs/base/common/objects.ts", "./vs/base/common/paths.ts", "./vs/base/common/platform.ts", + "./vs/base/common/range.ts", + "./vs/base/common/resources.ts", + "./vs/base/common/scanCode.ts", + "./vs/base/common/severity.ts", + "./vs/base/common/strings.ts", "./vs/base/common/uri.ts", + "./vs/base/common/urilpc.ts", "./vs/base/common/uuid.ts" ], "exclude": [ diff --git a/src/vs/base/common/color.ts b/src/vs/base/common/color.ts index 6dc7eb65aef..a8df525c7cb 100644 --- a/src/vs/base/common/color.ts +++ b/src/vs/base/common/color.ts @@ -416,7 +416,7 @@ export class Color { } toString(): string { - return Color.Format.CSS.format(this); + return '' + Color.Format.CSS.format(this); } static getLighterColor(of: Color, relative: Color, factor?: number): Color { diff --git a/src/vs/base/common/comparers.ts b/src/vs/base/common/comparers.ts index a1cf984e5ef..a3f3ca3582f 100644 --- a/src/vs/base/common/comparers.ts +++ b/src/vs/base/common/comparers.ts @@ -98,7 +98,7 @@ function noIntlCompareFileExtensions(one: string, other: string): number { } function extractNameAndExtension(str?: string): [string, string] { - const match = str ? FileNameMatch.exec(str) : [] as RegExpExecArray; + const match = str ? FileNameMatch.exec(str) as Array : ([] as Array); return [(match && match[1]) || '', (match && match[3]) || '']; } diff --git a/src/vs/base/common/decorators.ts b/src/vs/base/common/decorators.ts index ad829d14ff6..01478d3c3ad 100644 --- a/src/vs/base/common/decorators.ts +++ b/src/vs/base/common/decorators.ts @@ -5,8 +5,8 @@ export function createDecorator(mapFn: (fn: Function, key: string) => Function): Function { return (target: any, key: string, descriptor: any) => { - let fnKey: string = null; - let fn: Function = null; + let fnKey: string | null = null; + let fn: Function | null = null; if (typeof descriptor.value === 'function') { fnKey = 'value'; @@ -20,19 +20,19 @@ export function createDecorator(mapFn: (fn: Function, key: string) => Function): throw new Error('not supported'); } - descriptor[fnKey] = mapFn(fn, key); + descriptor[fnKey!] = mapFn(fn, key); }; } export function memoize(target: any, key: string, descriptor: any) { - let fnKey: string = null; - let fn: Function = null; + let fnKey: string | null = null; + let fn: Function | null = null; if (typeof descriptor.value === 'function') { fnKey = 'value'; fn = descriptor.value; - if (fn.length !== 0) { + if (fn!.length !== 0) { console.warn('Memoize should only be used in functions with zero parameters'); } } else if (typeof descriptor.get === 'function') { @@ -46,13 +46,13 @@ export function memoize(target: any, key: string, descriptor: any) { const memoizeKey = `$memoize$${key}`; - descriptor[fnKey] = function (...args: any[]) { + descriptor[fnKey!] = function (...args: any[]) { if (!this.hasOwnProperty(memoizeKey)) { Object.defineProperty(this, memoizeKey, { configurable: false, enumerable: false, writable: false, - value: fn.apply(this, args) + value: fn!.apply(this, args) }); } diff --git a/src/vs/base/common/keyCodes.ts b/src/vs/base/common/keyCodes.ts index 097578a6697..74352496c07 100644 --- a/src/vs/base/common/keyCodes.ts +++ b/src/vs/base/common/keyCodes.ts @@ -410,7 +410,7 @@ export function KeyChord(firstPart: number, secondPart: number): number { return (firstPart | chordPart) >>> 0; } -export function createKeybinding(keybinding: number, OS: OperatingSystem): Keybinding { +export function createKeybinding(keybinding: number, OS: OperatingSystem): Keybinding | null { if (keybinding === 0) { return null; } diff --git a/src/vs/base/common/lifecycle.ts b/src/vs/base/common/lifecycle.ts index 8b44cd2c687..405752fdb57 100644 --- a/src/vs/base/common/lifecycle.ts +++ b/src/vs/base/common/lifecycle.ts @@ -17,7 +17,7 @@ export function isDisposable(thing: E): thing is E & IDisposab export function dispose(disposable: T): T; export function dispose(...disposables: T[]): T[]; export function dispose(disposables: T[]): T[]; -export function dispose(first: T | T[], ...rest: T[]): T | T[] { +export function dispose(first: T | T[], ...rest: T[]): T | T[] | undefined { if (Array.isArray(first)) { first.forEach(d => d && d.dispose()); return []; diff --git a/src/vs/base/common/objects.ts b/src/vs/base/common/objects.ts index 2cc8e033d2b..5e90f440f07 100644 --- a/src/vs/base/common/objects.ts +++ b/src/vs/base/common/objects.ts @@ -218,7 +218,7 @@ export function safeStringify(obj: any): string { }); } -export function getOrDefault(obj: T, fn: (obj: T) => R, defaultValue: R = null): R { +export function getOrDefault(obj: T, fn: (obj: T) => R, defaultValue: R | null = null): R | null { const result = fn(obj); return typeof result === 'undefined' ? defaultValue : result; } diff --git a/src/vs/base/common/resources.ts b/src/vs/base/common/resources.ts index 811d2f38d79..7df851fa3db 100644 --- a/src/vs/base/common/resources.ts +++ b/src/vs/base/common/resources.ts @@ -72,7 +72,7 @@ export function basename(resource: URI): string { * @param resource The input URI. * @returns The URI representing the directory of the input URI. */ -export function dirname(resource: URI): URI { +export function dirname(resource: URI): URI | null { let dirname = paths.dirname(resource.path, '/'); if (resource.authority && dirname.length && dirname.charCodeAt(0) !== CharCode.Slash) { return null; // If a URI contains an authority component, then the path component must either be empty or begin with a CharCode.Slash ("/") character