Skip to content

Commit

Permalink
Fix all typescript errors when compiled in strict mode #1 (#4410)
Browse files Browse the repository at this point in the history
* few errors

* news entry

* code reviews
  • Loading branch information
Kartik Raj authored Feb 15, 2019
1 parent d30269b commit d014a00
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions news/3 Code Health/611.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix all typescript errors when compiled in strict mode
4 changes: 2 additions & 2 deletions src/client/activation/activationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export class LanguageServerExtensionActivationService implements IExtensionActiv
const activatedWkspcFoldersRemoved = activatedWkspcKeys.filter(item => workspaceKeys.indexOf(item) < 0);
if (activatedWkspcFoldersRemoved.length > 0) {
for (const folder of activatedWkspcFoldersRemoved) {
this.lsActivatedWorkspaces.get(folder).dispose();
this.lsActivatedWorkspaces.delete(folder);
this.lsActivatedWorkspaces.get(folder)!.dispose();
this.lsActivatedWorkspaces!.delete(folder);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class LanguageServerExtension implements ILanguageServerExtension {
this.disposable.dispose();
}
}
public register(): Promise<void> {
public async register(): Promise<void> {
if (this.disposable) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
} from 'vscode';
import * as vsls from 'vsls/vscode';

import { IAsyncDisposable } from '../types';
import { IAsyncDisposable, Resource } from '../types';

// tslint:disable:no-any unified-signatures

Expand Down Expand Up @@ -581,7 +581,7 @@ export interface IWorkspaceService {
* @param uri An uri.
* @return A workspace folder or `undefined`
*/
getWorkspaceFolder(uri: Uri): WorkspaceFolder | undefined;
getWorkspaceFolder(uri: Resource): WorkspaceFolder | undefined;

/**
* Generate a key that's unique to the workspace folder (could be fsPath).
Expand Down
4 changes: 2 additions & 2 deletions src/client/common/application/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class WorkspaceService implements IWorkspaceService {
public getConfiguration(section?: string, resource?: Uri): WorkspaceConfiguration {
return workspace.getConfiguration(section, resource);
}
public getWorkspaceFolder(uri: Uri): WorkspaceFolder | undefined {
return workspace.getWorkspaceFolder(uri);
public getWorkspaceFolder(uri: Resource): WorkspaceFolder | undefined {
return uri ? workspace.getWorkspaceFolder(uri) : undefined;
}
public asRelativePath(pathOrUri: string | Uri, includeWorkspaceFolder?: boolean): string {
return workspace.asRelativePath(pathOrUri, includeWorkspaceFolder);
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/variables/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function parseEnvFile(
baseVars?: EnvironmentVariables
): EnvironmentVariables {
const globalVars = baseVars ? baseVars : {};
const vars = {};
const vars : EnvironmentVariables = {};
lines.toString().split('\n').forEach((line, idx) => {
const [name, value] = parseEnvLine(line);
if (name === '') {
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/cellMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class CellMatcher {
}

public exec(code: string) : string | undefined {
let result: RegExpExecArray;
let result: RegExpExecArray | null = null;
if (this.codeMatchRegEx.test(code)) {
this.codeExecRegEx.lastIndex = -1;
result = this.codeExecRegEx.exec(code);
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/historyMessageListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ export class HistoryMessageListener implements IWebPanelMessageListener {
}

private getHistoryMessages() : string [] {
return Object.keys(HistoryMessages).map(k => HistoryMessages[k].toString());
return Object.keys(HistoryMessages).map(k => (HistoryMessages as any)[k].toString());
}
}
2 changes: 1 addition & 1 deletion src/client/datascience/liveshare/postOffice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class PostOffice implements IAsyncDisposable {
const jsonArray = JSON.parse(a.args) as JSONArray;
if (jsonArray !== null && jsonArray.length >= 2) {
const firstArg = jsonArray[0]; // More stupid hygiene problems.
const command = firstArg !== null ? firstArg.toString() : '';
const command = firstArg !== null ? firstArg!.toString() : '';
this.postCommand(command, ...jsonArray.slice(1)).ignoreErrors();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { IDebugConfigurationResolver } from '../types';

@injectable()
export abstract class BaseConfigurationResolver<T extends DebugConfiguration> implements IDebugConfigurationResolver<T> {
protected pythonPathSource: PythonPathSource;
protected pythonPathSource: PythonPathSource = PythonPathSource.launchJson;
constructor(protected readonly workspaceService: IWorkspaceService,
protected readonly documentManager: IDocumentManager,
protected readonly configurationService: IConfigurationService) { }
Expand Down
2 changes: 1 addition & 1 deletion src/client/providers/jediProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class JediProxy implements Disposable {
}

private static getProperty<T>(o: object, name: string): T {
return <T>o[name];
return <T>(o as any)[name];
}

public dispose() {
Expand Down
3 changes: 2 additions & 1 deletion src/client/providers/symbolProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function flattenSymbolTree(tree: DocumentSymbol, uri: Uri, containerName: string
tree.name,
// Type coercion is a bit fuzzy when it comes to enums, so we
// play it safe by explicitly converting.
SymbolKind[SymbolKind[kind]],
// tslint:disable-next-line:no-any
(SymbolKind as any)[(SymbolKind as any)[kind]],
containerName,
new Location(uri, range)
);
Expand Down
4 changes: 2 additions & 2 deletions src/client/terminals/codeExecution/djangoContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { IFileSystem } from '../../common/platform/types';
@injectable()
export class DjangoContextInitializer implements Disposable {
private readonly isDjangoProject: ContextKey;
private monitoringActiveTextEditor: boolean;
private monitoringActiveTextEditor: boolean = false;
private workspaceContextKeyValues = new Map<string, boolean>();
private lastCheckedWorkspace: string;
private lastCheckedWorkspace: string = '';
private disposables: Disposable[] = [];

constructor(private documentManager: IDocumentManager,
Expand Down
2 changes: 1 addition & 1 deletion src/client/typeFormatters/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class BlockRegEx {
constructor(private regEx: RegExp, public startWord) {
constructor(private regEx: RegExp, public startWord: String) {

}
public test(value: string): boolean {
Expand Down

0 comments on commit d014a00

Please sign in to comment.