@@ -107,14 +107,15 @@ export class TestMessageService implements ITestMessageService {
107107 testSourceFilePath = path . isAbsolute ( testSourceFilePath ) ? testSourceFilePath : path . resolve ( rootDirectory , testSourceFilePath ) ;
108108 const testSourceFileUri = Uri . file ( testSourceFilePath ) ;
109109 const testSourceFile = await workspace . openTextDocument ( testSourceFileUri ) ;
110- let testDefLine : TextLine | undefined ;
110+ let testDefLine : TextLine | null = null ;
111111 let lineNum = testFunction . testFunction . line ! ;
112112 let lineText : string = '' ;
113113 let trimmedLineText : string = '' ;
114114 const testDefPrefix = 'def ' ;
115115 const testAsyncDefPrefix = 'async def ' ;
116116 let prefix = '' ;
117- while ( testDefLine === undefined ) {
117+
118+ while ( testDefLine === null ) {
118119 const possibleTestDefLine = testSourceFile . lineAt ( lineNum ) ;
119120 lineText = possibleTestDefLine . text ;
120121 trimmedLineText = lineText . trimLeft ( ) ! ;
@@ -204,7 +205,7 @@ export class TestMessageService implements ITestMessageService {
204205 const lineClassName = matches ? matches [ 0 ] : undefined ;
205206
206207 // Check if the indentation is proper.
207- if ( parentIndentation === undefined ) {
208+ if ( parentIndentation === - 1 ) {
208209 // The parentIndentation hasn't been set yet, so we are looking for a class that was
209210 // defined in the global scope of the module.
210211 if ( trimmedLineText . length === lineText . length ) {
@@ -227,7 +228,7 @@ export class TestMessageService implements ITestMessageService {
227228 parentScopeEndIndex = index + 1 ;
228229 continue ;
229230 }
230- if ( prevLowestIndentation === undefined || indentation < prevLowestIndentation ) {
231+ if ( prevLowestIndentation === - 1 || indentation < prevLowestIndentation ) {
231232 if ( lineClassName === suiteName ) {
232233 // This might be the line that we want.
233234 suiteDefLineIndex = index ;
@@ -239,19 +240,19 @@ export class TestMessageService implements ITestMessageService {
239240 }
240241 }
241242 }
242- if ( suiteDefLineIndex === undefined ) {
243+ if ( suiteDefLineIndex === - 1 ) {
243244 // Could not find the suite declaration line, so give up and move on with the latest one that we found.
244245 break ;
245246 }
246247 // Found the line to process.
247248 parentScopeStartIndex = suiteDefLineIndex ;
248- parentIndentation = indentation ;
249+ parentIndentation = indentation ! ;
249250
250251 // Invert the index to get the unreversed equivalent.
251252 const realIndex = ( reversedTestFileLines . length - 1 ) - suiteDefLineIndex ;
252- const startChar = indentation + classPrefix . length ;
253+ const startChar = indentation ! + classPrefix . length ;
253254 const suiteStartPos = new Position ( realIndex , startChar ) ;
254- const suiteEndPos = new Position ( realIndex , ( startChar + suiteName . length ) ) ;
255+ const suiteEndPos = new Position ( realIndex , ( startChar + suiteName ! . length ) ) ;
255256 const suiteRange = new Range ( suiteStartPos , suiteEndPos ) ;
256257 const suiteLocation = new Location ( testFileUri , suiteRange ) ;
257258 suiteLocationStackFrameDetails . push ( { location : suiteLocation , lineText : testFile . getText ( suiteRange ) } ) ;
0 commit comments