@@ -1600,10 +1600,10 @@ namespace ts {
16001600
16011601 function makeGetTargetOfMappedPosition < TIn > (
16021602 extract : ( original : TIn ) => sourcemaps . SourceMappableLocation ,
1603- create : ( result : sourcemaps . SourceMappableLocation , original : TIn ) => TIn
1603+ create : ( result : sourcemaps . SourceMappableLocation , original : TIn , firstOriginal : TIn ) => TIn
16041604 ) {
16051605 return getTargetOfMappedPosition ;
1606- function getTargetOfMappedPosition ( input : TIn ) : TIn {
1606+ function getTargetOfMappedPosition ( input : TIn , firstOriginal = input ) : TIn {
16071607 const info = extract ( input ) ;
16081608 if ( endsWith ( info . fileName , Extension . Dts ) ) {
16091609 let file : SourceFileLike = program . getSourceFile ( info . fileName ) ;
@@ -1617,15 +1617,15 @@ namespace ts {
16171617 const mapper = getSourceMapper ( info . fileName , file ) ;
16181618 const newLoc = mapper . getOriginalPosition ( info ) ;
16191619 if ( newLoc === info ) return input ;
1620- return getTargetOfMappedPosition ( create ( newLoc , input ) ) ;
1620+ return getTargetOfMappedPosition ( create ( newLoc , input , firstOriginal ) , firstOriginal ) ;
16211621 }
16221622 return input ;
16231623 }
16241624 }
16251625
16261626 const getTargetOfMappedDeclarationInfo = makeGetTargetOfMappedPosition (
16271627 ( info : DefinitionInfo ) => ( { fileName : info . fileName , position : info . textSpan . start } ) ,
1628- ( newLoc , info ) => ( {
1628+ ( newLoc , info , firstOriginal ) => ( {
16291629 containerKind : info . containerKind ,
16301630 containerName : info . containerName ,
16311631 fileName : newLoc . fileName ,
@@ -1635,13 +1635,13 @@ namespace ts {
16351635 start : newLoc . position ,
16361636 length : info . textSpan . length
16371637 } ,
1638- originalFileName : info . fileName ,
1639- originalTextSpan : info . textSpan
1638+ originalFileName : firstOriginal . fileName ,
1639+ originalTextSpan : firstOriginal . textSpan
16401640 } )
16411641 ) ;
16421642
16431643 function getTargetOfMappedDeclarationFiles ( infos : ReadonlyArray < DefinitionInfo > ) : DefinitionInfo [ ] {
1644- return map ( infos , getTargetOfMappedDeclarationInfo ) ;
1644+ return map ( infos , d => getTargetOfMappedDeclarationInfo ( d ) ) ;
16451645 }
16461646
16471647 /// Goto definition
@@ -1687,7 +1687,7 @@ namespace ts {
16871687 ) ;
16881688
16891689 function getTargetOfMappedImplementationLocations ( infos : ReadonlyArray < ImplementationLocation > ) : ImplementationLocation [ ] {
1690- return map ( infos , getTargetOfMappedImplementationLocation ) ;
1690+ return map ( infos , d => getTargetOfMappedImplementationLocation ( d ) ) ;
16911691 }
16921692
16931693 function getImplementationAtPosition ( fileName : string , position : number ) : ImplementationLocation [ ] {
0 commit comments