提交 29d97683 编写于 作者: M Matt Bierner

Add null annotations for `x: T[] = null`

This code pattern indicates that the type should be nullable
上级 0318e90c
......@@ -347,7 +347,7 @@ class AnimationFrameQueueItem implements IDisposable {
/**
* The runners scheduled at the current animation frame
*/
let CURRENT_QUEUE: AnimationFrameQueueItem[] = null;
let CURRENT_QUEUE: AnimationFrameQueueItem[] | null = null;
/**
* A flag to keep track if the native requestAnimationFrame was already called
*/
......
......@@ -179,7 +179,7 @@ export class Tree implements _.ITree {
return this.model.collapse(element, recursive);
}
public collapseAll(elements: any[] = null, recursive: boolean = false): WinJS.Promise {
public collapseAll(elements: any[] | null = null, recursive: boolean = false): WinJS.Promise {
return this.model.collapseAll(elements, recursive);
}
......
......@@ -1030,7 +1030,7 @@ export class TreeModel {
return item.collapse(recursive);
}
public collapseAll(elements: any[] = null, recursive: boolean = false): WinJS.Promise {
public collapseAll(elements: any[] | null = null, recursive: boolean = false): WinJS.Promise {
if (!elements) {
elements = [this.input];
recursive = true;
......
......@@ -62,7 +62,7 @@ export function restoreFontInfo(storageService: IStorageService): void {
if (typeof strStoredFontInfo !== 'string') {
return;
}
let storedFontInfo: ISerializedFontInfo[] = null;
let storedFontInfo: ISerializedFontInfo[] | null = null;
try {
storedFontInfo = JSON.parse(strStoredFontInfo);
} catch (err) {
......
......@@ -250,7 +250,7 @@ export class TextAreaHandler extends ViewPart {
const metadata = LocalClipboardMetadataManager.INSTANCE.get(e.text);
let pasteOnNewLine = false;
let multicursorText: string[] = null;
let multicursorText: string[] | null = null;
if (metadata) {
pasteOnNewLine = (this._emptySelectionClipboard && metadata.isFromEmptySelection);
multicursorText = metadata.multicursorText;
......
......@@ -159,7 +159,7 @@ export class LanguagesRegistry {
resolvedLanguage.aliases.push(langId);
let langAliases: string[] = null;
let langAliases: string[] | null = null;
if (typeof lang.aliases !== 'undefined' && Array.isArray(lang.aliases)) {
if (lang.aliases.length === 0) {
// signal that this language should not get a name
......
......@@ -145,7 +145,7 @@ export class DragAndDropController implements editorCommon.IEditorContribution {
let newCursorPosition = new Position(mouseEvent.target.position.lineNumber, mouseEvent.target.position.column);
if (this._dragSelection === null) {
let newSelections: Selection[] = null;
let newSelections: Selection[] | null = null;
if (mouseEvent.event.shiftKey) {
let primarySelection = this._editor.getSelection();
let { selectionStartLineNumber, selectionStartColumn } = primarySelection;
......
......@@ -45,7 +45,7 @@ export class SyntaxRangeProvider implements RangeProvider {
}
function collectSyntaxRanges(providers: FoldingRangeProvider[], model: ITextModel, cancellationToken: CancellationToken): Thenable<IFoldingRangeData[] | null> {
let rangeData: IFoldingRangeData[] = null;
let rangeData: IFoldingRangeData[] | null = null;
let promises = providers.map((provider, i) => {
return Promise.resolve(provider.provideFoldingRanges(model, foldingContext, cancellationToken)).then(ranges => {
if (cancellationToken.isCancellationRequested) {
......
......@@ -476,7 +476,7 @@ export class MultiCursorSelectionController extends Disposable implements IEdito
}
public selectAll(findController: CommonFindController): void {
let matches: FindMatch[] = null;
let matches: FindMatch[] | null = null;
const findState = findController.getState();
......
......@@ -518,8 +518,8 @@ class MonarchTokenizer implements modes.ITokenizationSupport {
// regular expression group matching
// these never need cloning or equality since they are only used within a line match
let groupActions: monarchCommon.FuzzyAction[] = null;
let groupMatches: string[] = null;
let groupMatched: string[] = null;
let groupMatches: string[] | null = null;
let groupMatched: string[] | null = null;
let groupRule: monarchCommon.IRule = null;
while (pos < lineLength) {
......@@ -528,7 +528,7 @@ class MonarchTokenizer implements modes.ITokenizationSupport {
const groupLen0 = groupActions ? groupActions.length : 0;
const state = stack.state;
let matches: string[] = null;
let matches: string[] | null = null;
let matched: string | null = null;
let action: monarchCommon.FuzzyAction | monarchCommon.FuzzyAction[] = null;
let rule: monarchCommon.IRule = null;
......
......@@ -16,7 +16,7 @@ suite('TextModelSearch', () => {
const usualWordSeparators = getMapForWordSeparators(USUAL_WORD_SEPARATORS);
function assertFindMatch(actual: FindMatch, expectedRange: Range, expectedMatches: string[] = null): void {
function assertFindMatch(actual: FindMatch, expectedRange: Range, expectedMatches: string[] | null = null): void {
assert.deepEqual(actual, new FindMatch(expectedRange, expectedMatches));
}
......
......@@ -230,7 +230,7 @@ export class KeybindingResolver {
}
public resolve(context: IContext, currentChord: string, keypress: string): IResolveResult {
let lookupMap: ResolvedKeybindingItem[] = null;
let lookupMap: ResolvedKeybindingItem[] | null = null;
if (currentChord !== null) {
// Fetch all chord bindings for `currentChord`
......
......@@ -86,8 +86,8 @@ suite('AbstractKeybindingService', () => {
let currentContextValue: IContext | null = null;
let executeCommandCalls: { commandId: string; args: any[]; }[] = null;
let showMessageCalls: { sev: Severity, message: any; }[] = null;
let statusMessageCalls: string[] = null;
let statusMessageCallsDisposed: string[] = null;
let statusMessageCalls: string[] | null = null;
let statusMessageCallsDisposed: string[] | null = null;
setup(() => {
executeCommandCalls = [];
......
......@@ -32,7 +32,7 @@ export class MainThreadTextEditorProperties {
}
private static _readSelectionsFromCodeEditor(previousProperties: MainThreadTextEditorProperties, codeEditor: ICodeEditor): Selection[] {
let result: Selection[] = null;
let result: Selection[] | null = null;
if (codeEditor) {
result = codeEditor.getSelections();
}
......
......@@ -122,7 +122,7 @@ class ExtHostTreeView<T> extends Disposable {
private static LABEL_HANDLE_PREFIX = '0';
private static ID_HANDLE_PREFIX = '1';
private roots: TreeNode[] = null;
private roots: TreeNode[] | null = null;
private elements: Map<TreeItemHandle, T> = new Map<TreeItemHandle, T>();
private nodes: Map<T, TreeNode> = new Map<T, TreeNode>();
......
......@@ -141,7 +141,7 @@ export class LanguageConfigurationFileHandler {
return null;
}
let result: CharacterPair[] = null;
let result: CharacterPair[] | null = null;
for (let i = 0, len = source.length; i < len; i++) {
const pair = source[i];
if (!isCharacterPair(pair)) {
......@@ -165,7 +165,7 @@ export class LanguageConfigurationFileHandler {
return null;
}
let result: IAutoClosingPairConditional[] = null;
let result: IAutoClosingPairConditional[] | null = null;
for (let i = 0, len = source.length; i < len; i++) {
const pair = source[i];
if (Array.isArray(pair)) {
......@@ -211,7 +211,7 @@ export class LanguageConfigurationFileHandler {
return null;
}
let result: IAutoClosingPair[] = null;
let result: IAutoClosingPair[] | null = null;
for (let i = 0, len = source.length; i < len; i++) {
const pair = source[i];
if (Array.isArray(pair)) {
......
......@@ -123,7 +123,7 @@ const maven: TaskEntry = {
].join('\n')
};
let _templates: TaskEntry[] = null;
let _templates: TaskEntry[] | null = null;
export function getTemplates(): TaskEntry[] {
if (!_templates) {
_templates = [dotnetBuild, msbuild, maven].sort((a, b) => {
......
......@@ -1147,7 +1147,7 @@ export class StatResolver {
else {
// Convert the paths from options.resolveTo to absolute paths
let absoluteTargetPaths: string[] = null;
let absoluteTargetPaths: string[] | null = null;
if (options && options.resolveTo) {
absoluteTargetPaths = [];
options.resolveTo.forEach(resource => {
......
......@@ -254,11 +254,11 @@ export class KeybindingsEditorModel extends EditorModel {
class KeybindingItemMatches {
public readonly commandIdMatches: IMatch[] = null;
public readonly commandLabelMatches: IMatch[] = null;
public readonly commandDefaultLabelMatches: IMatch[] = null;
public readonly sourceMatches: IMatch[] = null;
public readonly whenMatches: IMatch[] = null;
public readonly commandIdMatches: IMatch[] | null = null;
public readonly commandLabelMatches: IMatch[] | null = null;
public readonly commandDefaultLabelMatches: IMatch[] | null = null;
public readonly sourceMatches: IMatch[] | null = null;
public readonly whenMatches: IMatch[] | null = null;
public readonly keybindingMatches: KeybindingMatches | null = null;
constructor(private modifierLabels: ModifierLabels, keybindingItem: IKeybindingItem, searchValue: string, words: string[], keybindingWords: string[], completeMatch: boolean) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册