@@ -7112,8 +7112,8 @@ namespace ts {
71127112 } ;
71137113 }
71147114
7115- export function chainDiagnosticMessages ( details : DiagnosticMessageChain | undefined , message : DiagnosticMessage , ...args : ( string | number | undefined ) [ ] ) : DiagnosticMessageChain ;
7116- export function chainDiagnosticMessages ( details : DiagnosticMessageChain | undefined , message : DiagnosticMessage ) : DiagnosticMessageChain {
7115+ export function chainDiagnosticMessages ( details : DiagnosticMessageChain | DiagnosticMessageChain [ ] | undefined , message : DiagnosticMessage , ...args : ( string | number | undefined ) [ ] ) : DiagnosticMessageChain ;
7116+ export function chainDiagnosticMessages ( details : DiagnosticMessageChain | DiagnosticMessageChain [ ] | undefined , message : DiagnosticMessage ) : DiagnosticMessageChain {
71177117 let text = getLocaleSpecificMessage ( message ) ;
71187118
71197119 if ( arguments . length > 2 ) {
@@ -7125,18 +7125,17 @@ namespace ts {
71257125 category : message . category ,
71267126 code : message . code ,
71277127
7128- next : details
7128+ next : details === undefined || Array . isArray ( details ) ? details : [ details ]
71297129 } ;
71307130 }
71317131
7132- export function concatenateDiagnosticMessageChains ( headChain : DiagnosticMessageChain , tailChain : DiagnosticMessageChain ) : DiagnosticMessageChain {
7132+ export function concatenateDiagnosticMessageChains ( headChain : DiagnosticMessageChain , tailChain : DiagnosticMessageChain ) : void {
71337133 let lastChain = headChain ;
71347134 while ( lastChain . next ) {
7135- lastChain = lastChain . next ;
7135+ lastChain = lastChain . next [ 0 ] ;
71367136 }
71377137
7138- lastChain . next = tailChain ;
7139- return headChain ;
7138+ lastChain . next = [ tailChain ] ;
71407139 }
71417140
71427141 function getDiagnosticFilePath ( diagnostic : Diagnostic ) : string | undefined {
@@ -7171,30 +7170,70 @@ namespace ts {
71717170 return d1 . relatedInformation ? Comparison . LessThan : Comparison . GreaterThan ;
71727171 }
71737172
7173+ // function compareMessageText(t1: string | DiagnosticMessageChain[], t2: string | DiagnosticMessageChain[]): Comparison {
7174+ // if (typeof t1 === 'string' && typeof t2 === 'string') {
7175+ // return compareStringsCaseSensitive(t1, t2)
7176+ // }
7177+ // else if (Array.isArray(t1) && Array.isArray(t2)) {
7178+ // if (t1.length < t2.length) {
7179+ // return Comparison.LessThan;
7180+ // }
7181+ // else if (t1.length > t2.length) {
7182+ // return Comparison.GreaterThan;
7183+ // }
7184+ // else {
7185+ // for (let i = 0; i < t1.length; i++) {
7186+ // t1[i].messageText
7187+ // const res = cmps(t1[i], t2[i]);
7188+ // if (res) {
7189+ // return res;
7190+ // }
7191+ // }
7192+ // return Comparison.EqualTo;
7193+ // }
7194+ // }
7195+ // else if (typeof t1 === 'string') {
7196+ // return Comparison.LessThan;
7197+ // }
7198+ // else {
7199+ // return Comparison.GreaterThan;
7200+ // }
7201+ // }
7202+
71747203 function compareMessageText ( t1 : string | DiagnosticMessageChain , t2 : string | DiagnosticMessageChain ) : Comparison {
7175- let text1 : string | DiagnosticMessageChain | undefined = t1 ;
7176- let text2 : string | DiagnosticMessageChain | undefined = t2 ;
7177- while ( text1 && text2 ) {
7178- // We still have both chains.
7179- const string1 = isString ( text1 ) ? text1 : text1 . messageText ;
7180- const string2 = isString ( text2 ) ? text2 : text2 . messageText ;
7181-
7182- const res = compareStringsCaseSensitive ( string1 , string2 ) ;
7204+ if ( typeof t1 === 'string' && typeof t2 === 'string' ) {
7205+ return compareStringsCaseSensitive ( t1 , t2 ) ;
7206+ }
7207+ else if ( typeof t1 === 'string' ) {
7208+ return Comparison . LessThan ;
7209+ }
7210+ else if ( typeof t2 === 'string' ) {
7211+ return Comparison . GreaterThan ;
7212+ }
7213+ let res = compareStringsCaseSensitive ( t1 . messageText , t2 . messageText ) ;
7214+ if ( res ) {
7215+ return res ;
7216+ }
7217+ if ( ! t1 . next && ! t2 . next ) {
7218+ return Comparison . EqualTo ;
7219+ }
7220+ if ( ! t1 . next ) {
7221+ return Comparison . LessThan ;
7222+ }
7223+ if ( ! t2 . next ) {
7224+ return Comparison . GreaterThan ;
7225+ }
7226+ res = compareValues ( t1 . next . length , t2 . next . length ) ;
7227+ if ( res ) {
7228+ return res ;
7229+ }
7230+ for ( let i = 0 ; i < t1 . next . length ; i ++ ) {
7231+ res = compareMessageText ( t1 . next [ i ] , t2 . next [ i ] )
71837232 if ( res ) {
71847233 return res ;
71857234 }
7186-
7187- text1 = isString ( text1 ) ? undefined : text1 . next ;
7188- text2 = isString ( text2 ) ? undefined : text2 . next ;
71897235 }
7190-
7191- if ( ! text1 && ! text2 ) {
7192- // if the chains are done, then these messages are the same.
7193- return Comparison . EqualTo ;
7194- }
7195-
7196- // We still have one chain remaining. The shorter chain should come first.
7197- return text1 ? Comparison . GreaterThan : Comparison . LessThan ;
7236+ return Comparison . EqualTo ;
71987237 }
71997238
72007239 export function getEmitScriptTarget ( compilerOptions : CompilerOptions ) {
0 commit comments