From f0c17fec4e8b8320a1e6e8e5ba985cafa6eb7964 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Fri, 1 Mar 2019 13:13:05 -0800 Subject: [PATCH] Fix all typescript errors when compiled in strict mode #3 (#4419) --- src/client/providers/symbolProvider.ts | 34 +++++++++---------- src/client/unittests/common/xUnitParser.ts | 2 +- src/client/unittests/display/main.ts | 2 +- .../unittests/explorer/commandHandlers.ts | 3 +- .../pytest/services/testMessageService.ts | 7 ++-- src/client/unittests/types.ts | 4 +-- src/test/debugger/misc.test.ts | 8 +++-- 7 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/client/providers/symbolProvider.ts b/src/client/providers/symbolProvider.ts index b3c21b2eb379..09cc55cc52ea 100644 --- a/src/client/providers/symbolProvider.ts +++ b/src/client/providers/symbolProvider.ts @@ -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 { - const filename = document.fileName; - - const cmd: proxy.ICommand = { - command: proxy.CommandType.Symbols, - fileName: filename, - columnIndex: 0, - lineIndex: 0 - }; - - if (document.isDirty) { - cmd.source = document.getText(); - } - - return this.jediFactory.getJediProxyHandler(document.uri).sendCommandNonCancellableCommand(cmd, token) - .then(data => this.parseData(document, data)); - } + // private provideDocumentSymbolsUnthrottled(document: TextDocument, token: CancellationToken): Thenable { + // const filename = document.fileName; + + // const cmd: proxy.ICommand = { + // command: proxy.CommandType.Symbols, + // fileName: filename, + // columnIndex: 0, + // lineIndex: 0 + // }; + + // if (document.isDirty) { + // cmd.source = document.getText(); + // } + + // return this.jediFactory.getJediProxyHandler(document.uri).sendCommandNonCancellableCommand(cmd, token) + // .then(data => this.parseData(document, data)); + // } private parseData(document: TextDocument, data?: proxy.ISymbolResult): SymbolInformation[] { if (data) { diff --git a/src/client/unittests/common/xUnitParser.ts b/src/client/unittests/common/xUnitParser.ts index f7089444ca0a..e315ae9b8341 100644 --- a/src/client/unittests/common/xUnitParser.ts +++ b/src/client/unittests/common/xUnitParser.ts @@ -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); } diff --git a/src/client/unittests/display/main.ts b/src/client/unittests/display/main.ts index bac14d2198ff..bfa81e105e7f 100644 --- a/src/client/unittests/display/main.ts +++ b/src/client/unittests/display/main.ts @@ -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(); diff --git a/src/client/unittests/explorer/commandHandlers.ts b/src/client/unittests/explorer/commandHandlers.ts index 837dc735b9a9..943129bd2014 100644 --- a/src/client/unittests/explorer/commandHandlers.ts +++ b/src/client/unittests/explorer/commandHandlers.ts @@ -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() diff --git a/src/client/unittests/pytest/services/testMessageService.ts b/src/client/unittests/pytest/services/testMessageService.ts index f3b3b843e3df..14a0dbbedd25 100644 --- a/src/client/unittests/pytest/services/testMessageService.ts +++ b/src/client/unittests/pytest/services/testMessageService.ts @@ -25,7 +25,7 @@ export class TestMessageService implements ITestMessageService { * @param testResults Details about all known tests. */ public async getFilteredTestMessages(rootDirectory: string, testResults: Tests): Promise { - const testFuncs: FlattenedTestFunction[] = testResults.testFunctions.reduce((filtered, test) => { + const testFuncs = testResults.testFunctions.reduce((filtered, test) => { if (test.testFunction.passed !== undefined || test.testFunction.status === TestStatus.Skipped) { filtered.push(test); } @@ -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()!; diff --git a/src/client/unittests/types.ts b/src/client/unittests/types.ts index fc0c4d5663e8..1ae1cfd460ca 100644 --- a/src/client/unittests/types.ts +++ b/src/client/unittests/types.ts @@ -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; } diff --git a/src/test/debugger/misc.test.ts b/src/test/debugger/misc.test.ts index fc341f37a8c6..55f08e6caecc 100644 --- a/src/test/debugger/misc.test.ts +++ b/src/test/debugger/misc.test.ts @@ -76,7 +76,9 @@ 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)), @@ -84,7 +86,9 @@ suite(`Standard Debugging - Misc tests: ${debuggerType}`, () => { 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)),