Skip to content

Commit 61168fc

Browse files
committed
Fixing / supressing more implict index errors
microsoft#76442
1 parent 6343b11 commit 61168fc

7 files changed

Lines changed: 24 additions & 25 deletions

File tree

src/vs/base/common/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ export function getAllPropertyNames(obj: object): string[] {
170170
}
171171

172172
export function getAllMethodNames(obj: object): string[] {
173-
let methods: string[] = [];
173+
const methods: string[] = [];
174174
for (const prop of getAllPropertyNames(obj)) {
175-
if (typeof obj[prop] === 'function') {
175+
if (typeof (obj as any)[prop] === 'function') {
176176
methods.push(prop);
177177
}
178178
}

src/vs/code/electron-main/window.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,10 @@ export class CodeWindow extends Disposable implements ICodeWindow {
584584
// Config (combination of process.argv and window configuration)
585585
const environment = parseArgs(process.argv);
586586
const config = objects.assign(environment, windowConfiguration);
587-
for (let key in config) {
588-
if (config[key] === undefined || config[key] === null || config[key] === '' || config[key] === false) {
589-
delete config[key]; // only send over properties that have a true value
587+
for (const key in config) {
588+
const configValue = (config as any)[key];
589+
if (configValue === undefined || configValue === null || configValue === '' || configValue === false) {
590+
delete (config as any)[key]; // only send over properties that have a true value
590591
}
591592
}
592593

src/vs/editor/standalone/browser/standaloneLanguages.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,11 @@ export interface EncodedTokensProvider {
290290
}
291291

292292
function isEncodedTokensProvider(provider: TokensProvider | EncodedTokensProvider): provider is EncodedTokensProvider {
293-
return provider['tokenizeEncoded'];
293+
return 'tokenizeEncoded' in provider;
294294
}
295295

296296
function isThenable<T>(obj: any): obj is Thenable<T> {
297-
if (typeof obj.then === 'function') {
298-
return true;
299-
}
300-
return false;
297+
return obj && typeof obj.then === 'function';
301298
}
302299

303300
/**

src/vs/workbench/browser/parts/editor/editorStatus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ export class ChangeModeAction extends Action {
10181018

10191019
// If the association is already being made in the workspace, make sure to target workspace settings
10201020
let target = ConfigurationTarget.USER;
1021-
if (fileAssociationsConfig.workspace && !!fileAssociationsConfig.workspace[associationKey]) {
1021+
if (fileAssociationsConfig.workspace && !!(fileAssociationsConfig.workspace as any)[associationKey]) {
10221022
target = ConfigurationTarget.WORKSPACE;
10231023
}
10241024

src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,11 +1117,12 @@ export class SettingsEditor2 extends BaseEditor {
11171117
const nlpResult = results[SearchResultIdx.Remote];
11181118
const nlpMetadata = nlpResult && nlpResult.metadata;
11191119

1120-
const durations = {};
1121-
durations['nlpResult'] = nlpMetadata && nlpMetadata.duration;
1120+
const durations = {
1121+
nlpResult: nlpMetadata && nlpMetadata.duration
1122+
};
11221123

11231124
// Count unique results
1124-
const counts = {};
1125+
const counts: { nlpResult?: number, filterResult?: number } = {};
11251126
const filterResult = results[SearchResultIdx.Local];
11261127
if (filterResult) {
11271128
counts['filterResult'] = filterResult.filterMatches.length;

src/vs/workbench/contrib/preferences/browser/settingsTree.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -702,17 +702,16 @@ export class SettingExcludeRenderer extends AbstractSettingRenderer implements I
702702
}
703703
}
704704

705-
const sortKeys = (obj: Object) => {
706-
const keyArray = Object.keys(obj)
707-
.map(key => ({ key, val: obj[key] }))
708-
.sort((a, b) => a.key.localeCompare(b.key));
709-
710-
const retVal = {};
711-
keyArray.forEach(pair => {
712-
retVal[pair.key] = pair.val;
713-
});
705+
function sortKeys<T extends object>(obj: T) {
706+
const sortedKeys = Object.keys(obj)
707+
.sort((a, b) => a.localeCompare(b)) as Array<keyof T>;
708+
709+
const retVal: Partial<T> = {};
710+
for (const key of sortedKeys) {
711+
retVal[key] = obj[key];
712+
}
714713
return retVal;
715-
};
714+
}
716715

717716
this._onDidChangeSetting.fire({
718717
key: template.context.setting.key,

src/vs/workbench/contrib/preferences/electron-browser/preferencesSearch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ExtensionType } from 'vs/platform/extensions/common/extensions';
1919
import { nullRange } from 'vs/workbench/services/preferences/common/preferencesModels';
2020
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2121
import { PreferencesSearchService as LocalPreferencesSearchService, SettingMatches } from 'vs/workbench/contrib/preferences/browser/preferencesSearch';
22+
import { IStringDictionary } from 'vs/base/common/collections';
2223

2324
export interface IEndpointDetails {
2425
urlBase?: string;
@@ -252,7 +253,7 @@ class RemoteSearchProvider implements ISearchProvider {
252253
}
253254

254255
const requestType = details.body ? 'post' : 'get';
255-
const headers = {
256+
const headers: IStringDictionary<string> = {
256257
'User-Agent': 'request',
257258
'Content-Type': 'application/json; charset=utf-8',
258259
};

0 commit comments

Comments
 (0)