@@ -7125,8 +7125,8 @@ namespace ts {
71257125 } ;
71267126 }
71277127
7128- export function chainDiagnosticMessages ( details : DiagnosticMessageChain | undefined , message : DiagnosticMessage , ...args : ( string | number | undefined ) [ ] ) : DiagnosticMessageChain ;
7129- export function chainDiagnosticMessages ( details : DiagnosticMessageChain | undefined , message : DiagnosticMessage ) : DiagnosticMessageChain {
7128+ export function chainDiagnosticMessages ( details : DiagnosticMessageChain | DiagnosticMessageChain [ ] | undefined , message : DiagnosticMessage , ...args : ( string | number | undefined ) [ ] ) : DiagnosticMessageChain ;
7129+ export function chainDiagnosticMessages ( details : DiagnosticMessageChain | DiagnosticMessageChain [ ] | undefined , message : DiagnosticMessage ) : DiagnosticMessageChain {
71307130 let text = getLocaleSpecificMessage ( message ) ;
71317131
71327132 if ( arguments . length > 2 ) {
@@ -7138,18 +7138,17 @@ namespace ts {
71387138 category : message . category ,
71397139 code : message . code ,
71407140
7141- next : details
7141+ next : details === undefined || Array . isArray ( details ) ? details : [ details ]
71427142 } ;
71437143 }
71447144
7145- export function concatenateDiagnosticMessageChains ( headChain : DiagnosticMessageChain , tailChain : DiagnosticMessageChain ) : DiagnosticMessageChain {
7145+ export function concatenateDiagnosticMessageChains ( headChain : DiagnosticMessageChain , tailChain : DiagnosticMessageChain ) : void {
71467146 let lastChain = headChain ;
71477147 while ( lastChain . next ) {
7148- lastChain = lastChain . next ;
7148+ lastChain = lastChain . next [ 0 ] ;
71497149 }
71507150
7151- lastChain . next = tailChain ;
7152- return headChain ;
7151+ lastChain . next = [ tailChain ] ;
71537152 }
71547153
71557154 function getDiagnosticFilePath ( diagnostic : Diagnostic ) : string | undefined {
@@ -7185,29 +7184,42 @@ namespace ts {
71857184 }
71867185
71877186 function compareMessageText ( t1 : string | DiagnosticMessageChain , t2 : string | DiagnosticMessageChain ) : Comparison {
7188- let text1 : string | DiagnosticMessageChain | undefined = t1 ;
7189- let text2 : string | DiagnosticMessageChain | undefined = t2 ;
7190- while ( text1 && text2 ) {
7191- // We still have both chains.
7192- const string1 = isString ( text1 ) ? text1 : text1 . messageText ;
7193- const string2 = isString ( text2 ) ? text2 : text2 . messageText ;
7194-
7195- const res = compareStringsCaseSensitive ( string1 , string2 ) ;
7187+ if ( typeof t1 === "string" && typeof t2 === "string" ) {
7188+ return compareStringsCaseSensitive ( t1 , t2 ) ;
7189+ }
7190+ else if ( typeof t1 === "string" ) {
7191+ return Comparison . LessThan ;
7192+ }
7193+ else if ( typeof t2 === "string" ) {
7194+ return Comparison . GreaterThan ;
7195+ }
7196+ let res = compareStringsCaseSensitive ( t1 . messageText , t2 . messageText ) ;
7197+ if ( res ) {
7198+ return res ;
7199+ }
7200+ if ( ! t1 . next && ! t2 . next ) {
7201+ return Comparison . EqualTo ;
7202+ }
7203+ if ( ! t1 . next ) {
7204+ return Comparison . LessThan ;
7205+ }
7206+ if ( ! t2 . next ) {
7207+ return Comparison . GreaterThan ;
7208+ }
7209+ const len = Math . min ( t1 . next . length , t2 . next . length ) ;
7210+ for ( let i = 0 ; i < len ; i ++ ) {
7211+ res = compareMessageText ( t1 . next [ i ] , t2 . next [ i ] ) ;
71967212 if ( res ) {
71977213 return res ;
71987214 }
7199-
7200- text1 = isString ( text1 ) ? undefined : text1 . next ;
7201- text2 = isString ( text2 ) ? undefined : text2 . next ;
72027215 }
7203-
7204- if ( ! text1 && ! text2 ) {
7205- // if the chains are done, then these messages are the same.
7206- return Comparison . EqualTo ;
7216+ if ( t1 . next . length < t2 . next . length ) {
7217+ return Comparison . LessThan ;
72077218 }
7208-
7209- // We still have one chain remaining. The shorter chain should come first.
7210- return text1 ? Comparison . GreaterThan : Comparison . LessThan ;
7219+ else if ( t1 . next . length > t2 . next . length ) {
7220+ return Comparison . GreaterThan ;
7221+ }
7222+ return Comparison . EqualTo ;
72117223 }
72127224
72137225 export function getEmitScriptTarget ( compilerOptions : CompilerOptions ) {
@@ -8105,7 +8117,7 @@ namespace ts {
81058117 visitDirectory ( basePath , combinePaths ( currentDirectory , basePath ) , depth ) ;
81068118 }
81078119
8108- return flatten < string > ( results ) ;
8120+ return flatten ( results ) ;
81098121
81108122 function visitDirectory ( path : string , absolutePath : string , depth : number | undefined ) {
81118123 const canonicalPath = toCanonical ( realpath ( absolutePath ) ) ;
0 commit comments