Skip to content

Commit 0318e90

Browse files
committed
Add null type annotations for the common x: T = null pattern
In these cases, the programmer has explicitly indicated that the type should be nullable
1 parent da546f5 commit 0318e90

130 files changed

Lines changed: 257 additions & 221 deletions

File tree

Some content is hidden

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

src/tsconfig.strictNullChecks.json

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,50 +91,80 @@
9191
"./vs/code/electron-main/keyboard.ts",
9292
"./vs/code/electron-main/theme.ts",
9393
"./vs/code/node/shellEnv.ts",
94+
"./vs/editor/browser/config/elementSizeObserver.ts",
95+
"./vs/editor/common/commands/replaceCommand.ts",
96+
"./vs/editor/common/commands/surroundSelectionCommand.ts",
9497
"./vs/editor/common/config/editorOptions.ts",
9598
"./vs/editor/common/config/editorZoom.ts",
9699
"./vs/editor/common/config/fontInfo.ts",
97100
"./vs/editor/common/controller/cursorEvents.ts",
98101
"./vs/editor/common/controller/wordCharacterClassifier.ts",
99102
"./vs/editor/common/core/characterClassifier.ts",
103+
"./vs/editor/common/core/editOperation.ts",
104+
"./vs/editor/common/core/lineTokens.ts",
100105
"./vs/editor/common/core/position.ts",
101106
"./vs/editor/common/core/range.ts",
102107
"./vs/editor/common/core/rgba.ts",
103108
"./vs/editor/common/core/selection.ts",
104109
"./vs/editor/common/core/stringBuilder.ts",
110+
"./vs/editor/common/core/token.ts",
105111
"./vs/editor/common/core/uint.ts",
112+
"./vs/editor/common/editorAction.ts",
113+
"./vs/editor/common/editorCommon.ts",
114+
"./vs/editor/common/editorContextKeys.ts",
106115
"./vs/editor/common/model.ts",
107116
"./vs/editor/common/model/editStack.ts",
117+
"./vs/editor/common/model/indentationGuesser.ts",
108118
"./vs/editor/common/model/intervalTree.ts",
109-
"./vs/editor/common/editorContextKeys.ts",
110119
"./vs/editor/common/model/mirrorTextModel.ts",
111120
"./vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase.ts",
112121
"./vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer.ts",
122+
"./vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder.ts",
113123
"./vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase.ts",
114124
"./vs/editor/common/model/textModel.ts",
115125
"./vs/editor/common/model/textModelEvents.ts",
116-
"./vs/editor/common/modes/languageSelector.ts",
117126
"./vs/editor/common/model/textModelSearch.ts",
118127
"./vs/editor/common/model/textModelTokens.ts",
119128
"./vs/editor/common/model/wordHelper.ts",
120129
"./vs/editor/common/modes.ts",
130+
"./vs/editor/common/modes/abstractMode.ts",
131+
"./vs/editor/common/modes/languageConfiguration.ts",
121132
"./vs/editor/common/modes/languageConfigurationRegistry.ts",
122133
"./vs/editor/common/modes/languageFeatureRegistry.ts",
134+
"./vs/editor/common/modes/languageSelector.ts",
123135
"./vs/editor/common/modes/nullMode.ts",
136+
"./vs/editor/common/modes/supports.ts",
137+
"./vs/editor/common/modes/supports/characterPair.ts",
124138
"./vs/editor/common/modes/supports/electricCharacter.ts",
139+
"./vs/editor/common/modes/supports/indentRules.ts",
125140
"./vs/editor/common/modes/supports/onEnter.ts",
126141
"./vs/editor/common/modes/supports/richEditBrackets.ts",
127142
"./vs/editor/common/modes/tokenizationRegistry.ts",
143+
"./vs/editor/common/services/editorWorkerService.ts",
144+
"./vs/editor/common/services/modeService.ts",
145+
"./vs/editor/common/services/modelService.ts",
146+
"./vs/editor/common/services/resolverService.ts",
128147
"./vs/editor/common/view/overviewZoneManager.ts",
129148
"./vs/editor/common/viewLayout/whitespaceComputer.ts",
130149
"./vs/editor/common/viewModel/prefixSumComputer.ts",
131150
"./vs/editor/contrib/codeAction/codeActionTrigger.ts",
151+
"./vs/editor/contrib/colorPicker/colorPickerModel.ts",
132152
"./vs/editor/contrib/find/findState.ts",
153+
"./vs/editor/contrib/find/replaceAllCommand.ts",
133154
"./vs/editor/contrib/find/replacePattern.ts",
155+
"./vs/editor/contrib/inPlaceReplace/inPlaceReplaceCommand.ts",
134156
"./vs/editor/contrib/indentation/indentUtils.ts",
157+
"./vs/editor/contrib/linesOperations/copyLinesCommand.ts",
135158
"./vs/editor/standalone/common/monarch/monarchCommon.ts",
136159
"./vs/editor/standalone/common/monarch/monarchCompile.ts",
137160
"./vs/editor/standalone/common/monarch/monarchTypes.ts",
161+
"./vs/editor/test/common/commentMode.ts",
162+
"./vs/editor/test/common/core/viewLineToken.ts",
163+
"./vs/editor/test/common/editorTestUtils.ts",
164+
"./vs/editor/test/common/mocks/mockMode.ts",
165+
"./vs/editor/test/common/model/benchmark/benchmarkUtils.ts",
166+
"./vs/editor/test/common/modes/supports/javascriptOnEnterRules.ts",
167+
"./vs/editor/test/common/modesTestUtils.ts",
138168
"./vs/nls.mock.ts",
139169
"./vs/platform/broadcast/electron-browser/broadcastService.ts",
140170
"./vs/platform/clipboard/common/clipboardService.ts",
@@ -191,17 +221,20 @@
191221
"./vs/workbench/common/extensionHostProtocol.ts",
192222
"./vs/workbench/common/panel.ts",
193223
"./vs/workbench/common/viewlet.ts",
224+
"./vs/workbench/parts/codeEditor/browser/simpleEditorOptions.ts",
194225
"./vs/workbench/parts/execution/common/execution.ts",
195226
"./vs/workbench/parts/extensions/common/extensionQuery.ts",
196227
"./vs/workbench/parts/logs/common/logConstants.ts",
197228
"./vs/workbench/parts/markers/electron-browser/constants.ts",
198229
"./vs/workbench/parts/outline/electron-browser/outline.ts",
199230
"./vs/workbench/parts/output/common/output.ts",
231+
"./vs/workbench/parts/scm/electron-browser/scmUtil.ts",
200232
"./vs/workbench/parts/search/common/constants.ts",
201233
"./vs/workbench/parts/terminal/browser/terminalWidgetManager.ts",
202234
"./vs/workbench/parts/terminal/common/terminal.ts",
203235
"./vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page.ts",
204236
"./vs/workbench/services/activity/common/activity.ts",
237+
"./vs/workbench/services/backup/common/backup.ts",
205238
"./vs/workbench/services/configuration/common/jsonEditing.ts",
206239
"./vs/workbench/services/decorations/browser/decorations.ts",
207240
"./vs/workbench/services/extensions/node/lazyPromise.ts",
@@ -212,7 +245,10 @@
212245
"./vs/workbench/services/hash/common/hashService.ts",
213246
"./vs/workbench/services/hash/node/hashService.ts",
214247
"./vs/workbench/services/panel/common/panelService.ts",
248+
"./vs/workbench/services/scm/common/scm.ts",
249+
"./vs/workbench/services/scm/common/scmService.ts",
215250
"./vs/workbench/services/search/node/search.ts",
251+
"./vs/workbench/services/textMate/electron-browser/textMateService.ts",
216252
"./vs/workbench/services/title/common/titleService.ts",
217253
"./vs/workbench/test/electron-browser/api/mock.ts"
218254
],

src/vs/base/browser/dom.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export function addDisposableNonBubblingMouseOutListener(node: Element, handler:
272272
interface IRequestAnimationFrame {
273273
(callback: (time: number) => void): number;
274274
}
275-
let _animationFrame: IRequestAnimationFrame = null;
275+
let _animationFrame: IRequestAnimationFrame | null = null;
276276
function doRequestAnimationFrame(callback: (time: number) => void): number {
277277
if (!_animationFrame) {
278278
const emulatedRequestAnimationFrame = (callback: (time: number) => void): any => {
@@ -425,7 +425,7 @@ class TimeoutThrottledDomListener<R, E extends DOMEvent> extends Disposable {
425425
constructor(node: any, type: string, handler: (event: R) => void, eventMerger: IEventMerger<R, E> = <any>DEFAULT_EVENT_MERGER, minimumTimeMs: number = MINIMUM_TIME_MS) {
426426
super();
427427

428-
let lastEvent: R = null;
428+
let lastEvent: R | null = null;
429429
let lastHandlerTime = 0;
430430
let timeout = this._register(new TimeoutTimer());
431431

@@ -771,7 +771,7 @@ export function createStyleSheet(container: HTMLElement = document.getElementsBy
771771
return style;
772772
}
773773

774-
let _sharedStyleSheet: HTMLStyleElement = null;
774+
let _sharedStyleSheet: HTMLStyleElement | null = null;
775775
function getSharedStyleSheet(): HTMLStyleElement {
776776
if (!_sharedStyleSheet) {
777777
_sharedStyleSheet = createStyleSheet();

src/vs/base/browser/ui/actionbar/actionbar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export class ActionItem extends BaseActionItem {
286286
}
287287

288288
updateTooltip(): void {
289-
let title: string = null;
289+
let title: string | null = null;
290290

291291
if (this.getAction().tooltip) {
292292
title = this.getAction().tooltip;
@@ -602,7 +602,7 @@ export class ActionBar extends Disposable implements IActionRunner {
602602
e.stopPropagation();
603603
}));
604604

605-
let item: IActionItem = null;
605+
let item: IActionItem | null = null;
606606

607607
if (this.options.actionItemProvider) {
608608
item = this.options.actionItemProvider(action);

src/vs/base/browser/ui/inputbox/inputBox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export class InputBox extends Widget {
260260
return document.activeElement === this.input;
261261
}
262262

263-
public select(range: IRange = null): void {
263+
public select(range: IRange | null = null): void {
264264
this.input.select();
265265

266266
if (range) {
@@ -339,7 +339,7 @@ export class InputBox extends Widget {
339339
}
340340

341341
public validate(): boolean {
342-
let errorMsg: IMessage = null;
342+
let errorMsg: IMessage | null = null;
343343

344344
if (this.validation) {
345345
errorMsg = this.validation(this.value);

src/vs/base/browser/ui/menu/menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ class MenuActionItem extends BaseActionItem {
347347
}
348348

349349
updateTooltip(): void {
350-
let title: string = null;
350+
let title: string | null = null;
351351

352352
if (this.getAction().tooltip) {
353353
title = this.getAction().tooltip;

src/vs/base/browser/ui/splitview/panelview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class PanelDraggable extends Disposable {
334334
}
335335

336336
private render(): void {
337-
let backgroundColor: string = null;
337+
let backgroundColor: string | null = null;
338338

339339
if (this.dragOverCounter > 0) {
340340
backgroundColor = (this.panel.dropBackground || PanelDraggable.DefaultDragOverBackgroundColor).toString();

src/vs/base/common/json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ export interface ParseOptions {
636636
* Therefore always check the errors list to find out if the input was valid.
637637
*/
638638
export function parse(text: string, errors: ParseError[] = [], options?: ParseOptions): any {
639-
let currentProperty: string = null;
639+
let currentProperty: string | null = null;
640640
let currentParent: any = [];
641641
let previousParents: any[] = [];
642642

src/vs/base/node/extfs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function rmRecursive(path: string, callback: (error: Error) => void): void {
252252
} else if (children.length === 0) {
253253
fs.rmdir(path, callback);
254254
} else {
255-
let firstError: Error = null;
255+
let firstError: Error | null = null;
256256
let childrenLeft = children.length;
257257
children.forEach(child => {
258258
rmRecursive(paths.join(path, child), (err: Error) => {
@@ -643,7 +643,7 @@ export function watch(path: string, onChange: (type: string, path?: string) => v
643643
const watcher = fs.watch(path);
644644

645645
watcher.on('change', (type, raw) => {
646-
let file: string = null;
646+
let file: string | null = null;
647647
if (raw) { // https://github.com/Microsoft/vscode/issues/38191
648648
file = raw.toString();
649649
if (platform.isMacintosh) {

src/vs/base/node/pfs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function fileExists(path: string): Promise<boolean> {
157157
/**
158158
* Deletes a path from disk.
159159
*/
160-
let _tmpDir: string = null;
160+
let _tmpDir: string | null = null;
161161
function getTmpDir(): string {
162162
if (!_tmpDir) {
163163
_tmpDir = os.tmpdir();

src/vs/base/parts/quickopen/browser/quickOpenModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class Renderer implements IRenderer<QuickOpenEntry> {
328328
private actionProvider: IActionProvider;
329329
private actionRunner: IActionRunner;
330330

331-
constructor(actionProvider: IActionProvider = new NoActionProvider(), actionRunner: IActionRunner = null) {
331+
constructor(actionProvider: IActionProvider = new NoActionProvider(), actionRunner: IActionRunner | null = null) {
332332
this.actionProvider = actionProvider;
333333
this.actionRunner = actionRunner;
334334
}

0 commit comments

Comments
 (0)