@@ -1811,7 +1811,7 @@ namespace ts.server {
18111811 return ( < protocol . FileLocationRequestArgs > locationOrSpan ) . line !== undefined ;
18121812 }
18131813
1814- private extractPositionAndRange ( args : protocol . FileLocationOrRangeRequestArgs , scriptInfo : ScriptInfo ) : { position : number , textRange : TextRange } {
1814+ private extractPositionOrRange ( args : protocol . FileLocationOrRangeRequestArgs , scriptInfo : ScriptInfo ) : number | TextRange {
18151815 let position : number | undefined ;
18161816 let textRange : TextRange | undefined ;
18171817 if ( this . isLocation ( args ) ) {
@@ -1821,7 +1821,7 @@ namespace ts.server {
18211821 const { startPosition, endPosition } = this . getStartAndEndPosition ( args , scriptInfo ) ;
18221822 textRange = { pos : startPosition , end : endPosition } ;
18231823 }
1824- return { position : position ! , textRange : textRange ! } ; // TODO: GH#18217
1824+ return Debug . assertDefined ( position === undefined ? textRange : position ) ;
18251825
18261826 function getPosition ( loc : protocol . FileLocationRequestArgs ) {
18271827 return loc . position !== undefined ? loc . position : scriptInfo . lineOffsetToPosition ( loc . line , loc . offset ) ;
@@ -1831,19 +1831,16 @@ namespace ts.server {
18311831 private getApplicableRefactors ( args : protocol . GetApplicableRefactorsRequestArgs ) : protocol . ApplicableRefactorInfo [ ] {
18321832 const { file, project } = this . getFileAndProject ( args ) ;
18331833 const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
1834- const { position, textRange } = this . extractPositionAndRange ( args , scriptInfo ) ;
1835- return project . getLanguageService ( ) . getApplicableRefactors ( file , position || textRange , this . getPreferences ( file ) ) ;
1834+ return project . getLanguageService ( ) . getApplicableRefactors ( file , this . extractPositionOrRange ( args , scriptInfo ) , this . getPreferences ( file ) ) ;
18361835 }
18371836
18381837 private getEditsForRefactor ( args : protocol . GetEditsForRefactorRequestArgs , simplifiedResult : boolean ) : RefactorEditInfo | protocol . RefactorEditInfo {
18391838 const { file, project } = this . getFileAndProject ( args ) ;
18401839 const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
1841- const { position, textRange } = this . extractPositionAndRange ( args , scriptInfo ) ;
1842-
18431840 const result = project . getLanguageService ( ) . getEditsForRefactor (
18441841 file ,
18451842 this . getFormatOptions ( file ) ,
1846- position || textRange ,
1843+ this . extractPositionOrRange ( args , scriptInfo ) ,
18471844 args . refactor ,
18481845 args . action ,
18491846 this . getPreferences ( file ) ,
0 commit comments