File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -681,10 +681,21 @@ namespace ts {
681681 return getSpanOfTokenAtPosition ( sourceFile , node . pos ) ;
682682 }
683683
684- const pos = nodeIsMissing ( errorNode )
684+ const isMissing = nodeIsMissing ( errorNode ) ;
685+ const pos = isMissing
685686 ? errorNode . pos
686687 : skipTrivia ( sourceFile . text , errorNode . pos ) ;
687688
689+ // These asserts should all be satisfied for a properly constructed `errorNode`.
690+ if ( isMissing ) {
691+ Debug . assert ( pos === errorNode . pos , "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809" ) ;
692+ Debug . assert ( pos === errorNode . end , "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809" ) ;
693+ }
694+ else {
695+ Debug . assert ( pos >= errorNode . pos , "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809" ) ;
696+ Debug . assert ( pos <= errorNode . end , "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809" ) ;
697+ }
698+
688699 return createTextSpanFromBounds ( pos , errorNode . end ) ;
689700 }
690701
Original file line number Diff line number Diff line change @@ -335,6 +335,13 @@ namespace ts.refactor.extractSymbol {
335335 Continue = 1 << 1 ,
336336 Return = 1 << 2
337337 }
338+
339+ // We believe it's true because the node is from the (unmodified) tree.
340+ Debug . assert ( nodeToCheck . pos <= nodeToCheck . end , "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809" ) ;
341+
342+ // For understanding how skipTrivia functioned:
343+ Debug . assert ( ! positionIsSynthesized ( nodeToCheck . pos ) , "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809" ) ;
344+
338345 if ( ! isStatement ( nodeToCheck ) && ! ( isExpressionNode ( nodeToCheck ) && isExtractableExpression ( nodeToCheck ) ) ) {
339346 return [ createDiagnosticForNode ( nodeToCheck , Messages . statementOrExpressionExpected ) ] ;
340347 }
You can’t perform that action at this time.
0 commit comments