Explicitly type simple array
Add typings for the pattern: `let x = []` which defaults to `let x: any[] = []` #60565
This commit is contained in:
parent
202c2b697f
commit
3cf3e16284
|
@ -191,7 +191,7 @@ export class Menu extends ActionBar {
|
|||
if (options.enableMnemonics) {
|
||||
const mnemonic = menuActionItem.getMnemonic();
|
||||
if (mnemonic && menuActionItem.isEnabled()) {
|
||||
let actionItems = [];
|
||||
let actionItems: MenuActionItem[] = [];
|
||||
if (this.mnemonics.has(mnemonic)) {
|
||||
actionItems = this.mnemonics.get(mnemonic);
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ export class Menu extends ActionBar {
|
|||
if (options.enableMnemonics) {
|
||||
const mnemonic = menuActionItem.getMnemonic();
|
||||
if (mnemonic && menuActionItem.isEnabled()) {
|
||||
let actionItems = [];
|
||||
let actionItems: MenuActionItem[] = [];
|
||||
if (this.mnemonics.has(mnemonic)) {
|
||||
actionItems = this.mnemonics.get(mnemonic);
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ suite('Arrays', () => {
|
|||
assert.equal(a[1], 2);
|
||||
assert.equal(a[2], 3);
|
||||
|
||||
let b = [];
|
||||
let b: number[] = [];
|
||||
b[10] = 1;
|
||||
b[20] = 2;
|
||||
b[30] = 3;
|
||||
|
@ -284,7 +284,7 @@ suite('Arrays', () => {
|
|||
assert.equal(b[1], 2);
|
||||
assert.equal(b[2], 3);
|
||||
|
||||
let sparse = [];
|
||||
let sparse: number[] = [];
|
||||
sparse[0] = 1;
|
||||
sparse[1] = 1;
|
||||
sparse[17] = 1;
|
||||
|
@ -312,7 +312,7 @@ suite('Arrays', () => {
|
|||
assert.equal(a[1], 2);
|
||||
assert.equal(a[2], 3);
|
||||
|
||||
let b = [];
|
||||
let b: number[] = [];
|
||||
b[10] = 1;
|
||||
b[20] = 2;
|
||||
b[30] = 3;
|
||||
|
@ -322,7 +322,7 @@ suite('Arrays', () => {
|
|||
assert.equal(b[1], 2);
|
||||
assert.equal(b[2], 3);
|
||||
|
||||
let sparse = [];
|
||||
let sparse: number[] = [];
|
||||
sparse[0] = 1;
|
||||
sparse[1] = 1;
|
||||
sparse[17] = 1;
|
||||
|
|
|
@ -114,7 +114,7 @@ suite('History Navigator', () => {
|
|||
});
|
||||
|
||||
function toArray(historyNavigator: HistoryNavigator<string>): string[] {
|
||||
let result = [];
|
||||
let result: string[] = [];
|
||||
historyNavigator.first();
|
||||
if (historyNavigator.current()) {
|
||||
do {
|
||||
|
|
|
@ -405,7 +405,7 @@ suite('SQLite Storage Library', () => {
|
|||
items.set('commandpalette.mru.cache', '{"usesLRU":true,"entries":[{"key":"revealFileInOS","value":3},{"key":"extension.openInGitHub","value":4},{"key":"workbench.extensions.action.openExtensionsFolder","value":11},{"key":"workbench.action.showRuntimeExtensions","value":14},{"key":"workbench.action.toggleTabsVisibility","value":15},{"key":"extension.liveServerPreview.open","value":16},{"key":"workbench.action.openIssueReporter","value":18},{"key":"workbench.action.openProcessExplorer","value":19},{"key":"workbench.action.toggleSharedProcess","value":20},{"key":"workbench.action.configureLocale","value":21},{"key":"workbench.action.appPerf","value":22},{"key":"workbench.action.reportPerformanceIssueUsingReporter","value":23},{"key":"workbench.action.openGlobalKeybindings","value":25},{"key":"workbench.action.output.toggleOutput","value":27},{"key":"extension.sayHello","value":29}]}');
|
||||
|
||||
let uuid = generateUuid();
|
||||
let value = [];
|
||||
let value: string[] = [];
|
||||
for (let i = 0; i < 100000; i++) {
|
||||
value.push(uuid);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
|||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { TimeoutTimer, CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IModelDeltaDecoration } from 'vs/editor/common/model';
|
||||
|
||||
const MAX_DECORATORS = 500;
|
||||
|
||||
|
@ -166,7 +167,7 @@ export class ColorDetector implements IEditorContribution {
|
|||
}
|
||||
|
||||
private updateColorDecorators(colorData: IColorData[]): void {
|
||||
let decorations = [];
|
||||
let decorations: IModelDeltaDecoration[] = [];
|
||||
let newDecorationsTypes: { [key: string]: boolean } = {};
|
||||
|
||||
for (let i = 0; i < colorData.length && decorations.length < MAX_DECORATORS; i++) {
|
||||
|
|
|
@ -77,7 +77,7 @@ export function getReindentEditOperations(model: ITextModel, startLineNumber: nu
|
|||
}
|
||||
|
||||
let { tabSize, insertSpaces } = model.getOptions();
|
||||
let indentEdits = [];
|
||||
let indentEdits: IIdentifiedSingleEditOperation[] = [];
|
||||
|
||||
// indentation being passed to lines below
|
||||
let globalIndent: string;
|
||||
|
|
|
@ -649,8 +649,8 @@ export class JoinLinesAction extends EditorAction {
|
|||
reducedSelections.push(lastSelection);
|
||||
|
||||
let model = editor.getModel();
|
||||
let edits = [];
|
||||
let endCursorState = [];
|
||||
let edits: IIdentifiedSingleEditOperation[] = [];
|
||||
let endCursorState: Selection[] = [];
|
||||
let endPrimaryCursor = primaryCursor;
|
||||
let lineOffset = 0;
|
||||
|
||||
|
|
|
@ -1868,7 +1868,7 @@ suite('Editor Controller - Regression tests', () => {
|
|||
this.timeout(10000);
|
||||
const LINE_CNT = 2000;
|
||||
|
||||
let text = [];
|
||||
let text: string[] = [];
|
||||
for (let i = 0; i < LINE_CNT; i++) {
|
||||
text[i] = 'asd';
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ function assertDiff(originalLines: string[], modifiedLines: string[], expectedCh
|
|||
});
|
||||
let changes = diffComputer.computeDiff();
|
||||
|
||||
let extracted = [];
|
||||
let extracted: IChange[] = [];
|
||||
for (let i = 0; i < changes.length; i++) {
|
||||
extracted.push(extractLineChangeRepresentation(changes[i], <ILineChange>(i < expectedChanges.length ? expectedChanges[i] : null)));
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ export function getRandomString(minLength: number, maxLength: number): string {
|
|||
}
|
||||
|
||||
export function generateRandomEdits(chunks: string[], editCnt: number): IIdentifiedSingleEditOperation[] {
|
||||
let lines = [];
|
||||
let lines: string[] = [];
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
let newLines = chunks[i].split(/\r\n|\r|\n/);
|
||||
if (lines.length === 0) {
|
||||
|
@ -65,7 +65,7 @@ export function generateRandomEdits(chunks: string[], editCnt: number): IIdentif
|
|||
}
|
||||
|
||||
export function generateSequentialInserts(chunks: string[], editCnt: number): IIdentifiedSingleEditOperation[] {
|
||||
let lines = [];
|
||||
let lines: string[] = [];
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
let newLines = chunks[i].split(/\r\n|\r|\n/);
|
||||
if (lines.length === 0) {
|
||||
|
@ -100,7 +100,7 @@ export function generateSequentialInserts(chunks: string[], editCnt: number): II
|
|||
}
|
||||
|
||||
export function generateRandomReplaces(chunks: string[], editCnt: number, searchStringLen: number, replaceStringLen: number): IIdentifiedSingleEditOperation[] {
|
||||
let lines = [];
|
||||
let lines: string[] = [];
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
let newLines = chunks[i].split(/\r\n|\r|\n/);
|
||||
if (lines.length === 0) {
|
||||
|
|
|
@ -49,7 +49,7 @@ function addDecoration(model: TextModel, startLineNumber: number, startColumn: n
|
|||
}
|
||||
|
||||
function lineHasDecorations(model: TextModel, lineNumber: number, decorations: { start: number; end: number; className: string; }[]) {
|
||||
let lineDecorations = [];
|
||||
let lineDecorations: Array<{ start: number; end: number; className: string; }> = [];
|
||||
let decs = model.getLineDecorations(lineNumber);
|
||||
for (let i = 0, len = decs.length; i < len; i++) {
|
||||
lineDecorations.push({
|
||||
|
|
|
@ -1515,7 +1515,7 @@ suite('random is unsupervised', () => {
|
|||
|
||||
test('random chunks', function () {
|
||||
this.timeout(500000);
|
||||
let chunks = [];
|
||||
let chunks: string[] = [];
|
||||
for (let i = 0; i < 5; i++) {
|
||||
chunks.push(randomStr(1000));
|
||||
}
|
||||
|
@ -1550,7 +1550,7 @@ suite('random is unsupervised', () => {
|
|||
|
||||
test('random chunks 2', function () {
|
||||
this.timeout(500000);
|
||||
let chunks = [];
|
||||
let chunks: string[] = [];
|
||||
chunks.push(randomStr(1000));
|
||||
|
||||
let pieceTable = createTextBuffer(chunks, false);
|
||||
|
|
|
@ -89,7 +89,7 @@ export class ConfigurationService extends Disposable implements IConfigurationSe
|
|||
}
|
||||
|
||||
private onDidChangeUserConfiguration(): void {
|
||||
let changedKeys = [];
|
||||
let changedKeys: string[] = [];
|
||||
const { added, updated, removed } = compare(this._configuration.user, this.userConfiguration.configurationModel);
|
||||
changedKeys = [...added, ...updated, ...removed];
|
||||
if (changedKeys.length) {
|
||||
|
|
|
@ -151,7 +151,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
|||
}
|
||||
|
||||
getVisibleEditors(): ICodeEditor[] {
|
||||
let ret = [];
|
||||
let ret: ICodeEditor[] = [];
|
||||
|
||||
this._editorService.visibleControls.forEach(control => {
|
||||
if (isCodeEditor(control.getControl())) {
|
||||
|
|
|
@ -128,7 +128,7 @@ class CommentingRangeDecorator {
|
|||
return;
|
||||
}
|
||||
|
||||
let commentingRangeDecorations = [];
|
||||
let commentingRangeDecorations: CommentingRangeDecoration[] = [];
|
||||
for (let i = 0; i < commentInfos.length; i++) {
|
||||
let info = commentInfos[i];
|
||||
info.commentingRanges.forEach(range => {
|
||||
|
@ -470,7 +470,7 @@ export class ReviewController implements IEditorContribution {
|
|||
if (this._commentInfos.some(info => Boolean(info.commentingRanges && info.commentingRanges.length))) {
|
||||
if (!this._commentingRangeSpaceReserved) {
|
||||
this._commentingRangeSpaceReserved = true;
|
||||
let extraEditorClassName = [];
|
||||
let extraEditorClassName: string[] = [];
|
||||
if (this.editor.getRawConfiguration().extraEditorClassName) {
|
||||
extraEditorClassName = this.editor.getRawConfiguration().extraEditorClassName.split(' ');
|
||||
}
|
||||
|
|
|
@ -1344,7 +1344,7 @@ export class InstallWorkspaceRecommendedExtensionsAction extends Action {
|
|||
viewlet.focus();
|
||||
const names = this.recommendations.map(({ extensionId }) => extensionId);
|
||||
return this.extensionWorkbenchService.queryGallery({ names, source: 'install-all-workspace-recommendations' }).then(pager => {
|
||||
let installPromises = [];
|
||||
let installPromises: Thenable<void>[] = [];
|
||||
let model = new PagedModel(pager);
|
||||
for (let i = 0; i < pager.total; i++) {
|
||||
installPromises.push(model.resolve(i, CancellationToken.None).then(e => {
|
||||
|
|
|
@ -90,7 +90,7 @@ export class ExtensionsViewletViewsContribution implements IWorkbenchContributio
|
|||
}
|
||||
|
||||
private registerViews(): void {
|
||||
let viewDescriptors = [];
|
||||
let viewDescriptors: IViewDescriptor[] = [];
|
||||
viewDescriptors.push(this.createMarketPlaceExtensionsListViewDescriptor());
|
||||
viewDescriptors.push(this.createEnabledExtensionsListViewDescriptor());
|
||||
viewDescriptors.push(this.createDisabledExtensionsListViewDescriptor());
|
||||
|
|
|
@ -60,7 +60,7 @@ export class ExplorerViewletViewsContribution extends Disposable implements IWor
|
|||
private registerViews(): void {
|
||||
const viewDescriptors = ViewsRegistry.getViews(VIEW_CONTAINER);
|
||||
|
||||
let viewDescriptorsToRegister = [];
|
||||
let viewDescriptorsToRegister: IViewDescriptor[] = [];
|
||||
let viewDescriptorsToDeregister: string[] = [];
|
||||
|
||||
const openEditorsViewDescriptor = this.createOpenEditorsViewDescriptor();
|
||||
|
|
|
@ -172,7 +172,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
|
|||
this.onConfigurationUpdated(configuration);
|
||||
|
||||
// Load and Fill Viewer
|
||||
let targetsToExpand = [];
|
||||
let targetsToExpand: URI[] = [];
|
||||
if (this.viewState[ExplorerView.MEMENTO_EXPANDED_FOLDER_RESOURCES]) {
|
||||
targetsToExpand = this.viewState[ExplorerView.MEMENTO_EXPANDED_FOLDER_RESOURCES].map((e: string) => URI.parse(e));
|
||||
}
|
||||
|
|
|
@ -468,7 +468,7 @@ export class OpenEditorsView extends ViewletPanel {
|
|||
|
||||
public getOptimalWidth(): number {
|
||||
let parentNode = this.list.getHTMLElement();
|
||||
let childNodes = [].slice.call(parentNode.querySelectorAll('.open-editor > a'));
|
||||
let childNodes: HTMLElement[] = [].slice.call(parentNode.querySelectorAll('.open-editor > a'));
|
||||
|
||||
return dom.getLargestChildWidth(parentNode, childNodes);
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
|
|||
const mode = this.modeService.getOrCreateMode('jsonc');
|
||||
const model = this.modelService.createModel(modelContent, mode, uri);
|
||||
|
||||
let disposables = [];
|
||||
let disposables: IDisposable[] = [];
|
||||
disposables.push(schemaRegistry.onDidChangeSchema(schemaUri => {
|
||||
if (schemaUri === uri.toString()) {
|
||||
schema = schemaRegistry.getSchemaContributions().schemas[uri.toString()];
|
||||
|
|
|
@ -198,7 +198,7 @@ class GenerateColorThemeAction extends Action {
|
|||
let colors = Registry.as<IColorRegistry>(ColorRegistryExtensions.ColorContribution).getColors();
|
||||
let colorIds = colors.map(c => c.id).sort();
|
||||
let resultingColors = {};
|
||||
let inherited = [];
|
||||
let inherited: string[] = [];
|
||||
for (let colorId of colorIds) {
|
||||
const color = theme.getColor(colorId, false);
|
||||
if (color) {
|
||||
|
|
|
@ -315,8 +315,8 @@ class KeybindingItemMatches {
|
|||
let chordPartMatch: KeybindingMatch = {};
|
||||
|
||||
const matchedWords = [];
|
||||
let firstPartMatchedWords = [];
|
||||
let chordPartMatchedWords = [];
|
||||
let firstPartMatchedWords: number[] = [];
|
||||
let chordPartMatchedWords: number[] = [];
|
||||
let matchFirstPart = true;
|
||||
for (let index = 0; index < words.length; index++) {
|
||||
const word = words[index];
|
||||
|
|
|
@ -1099,7 +1099,7 @@ export function createValidator(prop: IConfigurationPropertySchema): ((value: an
|
|||
if (prop.type === 'string' && stringValidations.length === 0) { return null; }
|
||||
if (isNullable && value === '') { return ''; }
|
||||
|
||||
let errors = [];
|
||||
let errors: string[] = [];
|
||||
|
||||
if (isNumeric) {
|
||||
if (value === '' || isNaN(+value)) {
|
||||
|
|
Loading…
Reference in a new issue