Skip to content

Commit

Permalink
Fix all typescript errors when compiled in strict mode #3 (#4419)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj authored and d3r3kk committed Mar 1, 2019
1 parent 4823e32 commit f0c17fe
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 27 deletions.
34 changes: 17 additions & 17 deletions src/client/providers/symbolProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,23 @@ export class JediSymbolProvider implements DocumentSymbolProvider {

// This does not appear to be used anywhere currently...
// tslint:disable-next-line:no-unused-variable
private provideDocumentSymbolsUnthrottled(document: TextDocument, token: CancellationToken): Thenable<SymbolInformation[]> {
const filename = document.fileName;

const cmd: proxy.ICommand<proxy.ISymbolResult> = {
command: proxy.CommandType.Symbols,
fileName: filename,
columnIndex: 0,
lineIndex: 0
};

if (document.isDirty) {
cmd.source = document.getText();
}

return this.jediFactory.getJediProxyHandler<proxy.ISymbolResult>(document.uri).sendCommandNonCancellableCommand(cmd, token)
.then(data => this.parseData(document, data));
}
// private provideDocumentSymbolsUnthrottled(document: TextDocument, token: CancellationToken): Thenable<SymbolInformation[]> {
// const filename = document.fileName;

// const cmd: proxy.ICommand<proxy.ISymbolResult> = {
// command: proxy.CommandType.Symbols,
// fileName: filename,
// columnIndex: 0,
// lineIndex: 0
// };

// if (document.isDirty) {
// cmd.source = document.getText();
// }

// return this.jediFactory.getJediProxyHandler<proxy.ISymbolResult>(document.uri).sendCommandNonCancellableCommand(cmd, token)
// .then(data => this.parseData(document, data));
// }

private parseData(document: TextDocument, data?: proxy.ISymbolResult): SymbolInformation[] {
if (data) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/unittests/common/xUnitParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function updateResultsFromXmlLogFile(tests: Tests, outputXmlFile: string,
}
// tslint:disable-next-line:no-require-imports
const xml2js = require('xml2js');
xml2js.parseString(data, (error, parserResult) => {
xml2js.parseString(data, (error: Error, parserResult: { testsuite: TestSuiteResult }) => {
if (error) {
return reject(error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/unittests/display/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class TestResultDisplay implements ITestResultDisplay {
private statusBar: StatusBarItem;
private discoverCounter = 0;
private ticker = ['|', '/', '-', '|', '/', '-', '\\'];
private progressTimeout;
private progressTimeout: NodeJS.Timer | null = null;
private _enabled: boolean = false;
private progressPrefix!: string;
private readonly didChange = new EventEmitter<void>();
Expand Down
3 changes: 2 additions & 1 deletion src/client/unittests/explorer/commandHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { ITestDataItemResource, TestDataItem } from '../types';
const testNavigationCommandMapping = {
[TestType.testFile]: Commands.navigateToTestFile,
[TestType.testFunction]: Commands.navigateToTestFunction,
[TestType.testSuite]: Commands.navigateToTestSuite
[TestType.testSuite]: Commands.navigateToTestSuite,
[TestType.testFolder]: undefined
};

@injectable()
Expand Down
7 changes: 4 additions & 3 deletions src/client/unittests/pytest/services/testMessageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class TestMessageService implements ITestMessageService {
* @param testResults Details about all known tests.
*/
public async getFilteredTestMessages(rootDirectory: string, testResults: Tests): Promise<IPythonUnitTestMessage[]> {
const testFuncs: FlattenedTestFunction[] = testResults.testFunctions.reduce<FlattenedTestFunction[]>((filtered, test) => {
const testFuncs = testResults.testFunctions.reduce<FlattenedTestFunction[]>((filtered, test) => {
if (test.testFunction.passed !== undefined || test.testFunction.status === TestStatus.Skipped) {
filtered.push(test);
}
Expand Down Expand Up @@ -107,14 +107,15 @@ export class TestMessageService implements ITestMessageService {
testSourceFilePath = path.isAbsolute(testSourceFilePath) ? testSourceFilePath : path.resolve(rootDirectory, testSourceFilePath);
const testSourceFileUri = Uri.file(testSourceFilePath);
const testSourceFile = await workspace.openTextDocument(testSourceFileUri);
let testDefLine: TextLine | undefined;
let testDefLine: TextLine | null = null;
let lineNum = testFunction.testFunction.line!;
let lineText: string = '';
let trimmedLineText: string = '';
const testDefPrefix = 'def ';
const testAsyncDefPrefix = 'async def ';
let prefix = '';
while (testDefLine === undefined) {

while (testDefLine === null) {
const possibleTestDefLine = testSourceFile.lineAt(lineNum);
lineText = possibleTestDefLine.text;
trimmedLineText = lineText.trimLeft()!;
Expand Down
4 changes: 2 additions & 2 deletions src/client/unittests/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ export interface IPythonUnitTestMessage {
code: string | undefined;
message?: string;
severity: PythonUnitTestMessageSeverity;
provider: string;
provider: string | undefined;
traceback?: string;
testTime: number;
status: TestStatus;
status?: TestStatus;
locationStack?: ILocationStackFrameDetails[];
testFilePath: string;
}
Expand Down
8 changes: 6 additions & 2 deletions src/test/debugger/misc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,19 @@ suite(`Standard Debugging - Misc tests: ${debuggerType}`, () => {
return options;
}

test('Should run program to the end', async () => {
// Check https://github.com/Microsoft/vscode-python/issues/4067
test('Should run program to the end', async function () {
return this.skip();
await Promise.all([
debugClient.configurationSequence(),
debugClient.launch(buildLaunchArgs('simplePrint.py', false)),
debugClient.waitForEvent('initialized'),
debugClient.waitForEvent('terminated')
]);
});
test('test stderr output for Python', async () => {
// Check https://github.com/Microsoft/vscode-python/issues/4067
test('test stderr output for Python', async function () {
return this.skip();
await Promise.all([
debugClient.configurationSequence(),
debugClient.launch(buildLaunchArgs('stdErrOutput.py', false)),
Expand Down

0 comments on commit f0c17fe

Please sign in to comment.