@@ -8121,8 +8121,8 @@ export function setObjectAllocator(alloc: ObjectAllocator) {
81218121}
81228122
81238123/** @internal */
8124- export function formatStringFromArgs ( text : string , args : ArrayLike < string | number > , baseIndex = 0 ) : string {
8125- return text . replace ( / { ( \d + ) } / g, ( _match , index : string ) => "" + Debug . checkDefined ( args [ + index + baseIndex ] ) ) ;
8124+ export function formatStringFromArgs ( text : string , args : DiagnosticArguments ) : string {
8125+ return text . replace ( / { ( \d + ) } / g, ( _match , index : string ) => "" + Debug . checkDefined ( args [ + index ] ) ) ;
81268126}
81278127
81288128let localizedDiagnosticMessages : MapLike < string > | undefined ;
@@ -8147,14 +8147,12 @@ export function getLocaleSpecificMessage(message: DiagnosticMessage) {
81478147}
81488148
81498149/** @internal */
8150- export function createDetachedDiagnostic ( fileName : string , start : number , length : number , message : DiagnosticMessage , ...args : DiagnosticArguments ) : DiagnosticWithDetachedLocation ;
8151- /** @internal */
8152- export function createDetachedDiagnostic ( fileName : string , start : number , length : number , message : DiagnosticMessage ) : DiagnosticWithDetachedLocation {
8150+ export function createDetachedDiagnostic ( fileName : string , start : number , length : number , message : DiagnosticMessage , ...args : DiagnosticArguments ) : DiagnosticWithDetachedLocation {
81538151 assertDiagnosticLocation ( /*file*/ undefined , start , length ) ;
81548152 let text = getLocaleSpecificMessage ( message ) ;
81558153
8156- if ( arguments . length > 4 ) {
8157- text = formatStringFromArgs ( text , arguments , 4 ) ;
8154+ if ( some ( args ) ) {
8155+ text = formatStringFromArgs ( text , args ) ;
81588156 }
81598157
81608158 return {
@@ -8218,15 +8216,13 @@ export function attachFileToDiagnostics(diagnostics: DiagnosticWithDetachedLocat
82188216}
82198217
82208218/** @internal */
8221- export function createFileDiagnostic ( file : SourceFile , start : number , length : number , message : DiagnosticMessage , ...args : DiagnosticArguments ) : DiagnosticWithLocation ;
8222- /** @internal */
8223- export function createFileDiagnostic ( file : SourceFile , start : number , length : number , message : DiagnosticMessage ) : DiagnosticWithLocation {
8219+ export function createFileDiagnostic ( file : SourceFile , start : number , length : number , message : DiagnosticMessage , ...args : DiagnosticArguments ) : DiagnosticWithLocation {
82248220 assertDiagnosticLocation ( file , start , length ) ;
82258221
82268222 let text = getLocaleSpecificMessage ( message ) ;
82278223
8228- if ( arguments . length > 4 ) {
8229- text = formatStringFromArgs ( text , arguments , 4 ) ;
8224+ if ( some ( args ) ) {
8225+ text = formatStringFromArgs ( text , args ) ;
82308226 }
82318227
82328228 return {
@@ -8243,26 +8239,22 @@ export function createFileDiagnostic(file: SourceFile, start: number, length: nu
82438239}
82448240
82458241/** @internal */
8246- export function formatMessage ( _dummy : any , message : DiagnosticMessage , ...args : DiagnosticArguments ) : string ;
8247- /** @internal */
8248- export function formatMessage ( _dummy : any , message : DiagnosticMessage ) : string {
8242+ export function formatMessage ( message : DiagnosticMessage , ...args : DiagnosticArguments ) : string {
82498243 let text = getLocaleSpecificMessage ( message ) ;
82508244
8251- if ( arguments . length > 2 ) {
8252- text = formatStringFromArgs ( text , arguments , 2 ) ;
8245+ if ( some ( args ) ) {
8246+ text = formatStringFromArgs ( text , args ) ;
82538247 }
82548248
82558249 return text ;
82568250}
82578251
82588252/** @internal */
8259- export function createCompilerDiagnostic ( message : DiagnosticMessage , ...args : DiagnosticArguments ) : Diagnostic ;
8260- /** @internal */
8261- export function createCompilerDiagnostic ( message : DiagnosticMessage ) : Diagnostic {
8253+ export function createCompilerDiagnostic ( message : DiagnosticMessage , ...args : DiagnosticArguments ) : Diagnostic {
82628254 let text = getLocaleSpecificMessage ( message ) ;
82638255
8264- if ( arguments . length > 1 ) {
8265- text = formatStringFromArgs ( text , arguments , 1 ) ;
8256+ if ( some ( args ) ) {
8257+ text = formatStringFromArgs ( text , args ) ;
82668258 }
82678259
82688260 return {
@@ -8293,13 +8285,11 @@ export function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessag
82938285}
82948286
82958287/** @internal */
8296- export function chainDiagnosticMessages ( details : DiagnosticMessageChain | DiagnosticMessageChain [ ] | undefined , message : DiagnosticMessage , ...args : DiagnosticArguments ) : DiagnosticMessageChain ;
8297- /** @internal */
8298- export function chainDiagnosticMessages ( details : DiagnosticMessageChain | DiagnosticMessageChain [ ] | undefined , message : DiagnosticMessage ) : DiagnosticMessageChain {
8288+ export function chainDiagnosticMessages ( details : DiagnosticMessageChain | DiagnosticMessageChain [ ] | undefined , message : DiagnosticMessage , ...args : DiagnosticArguments ) : DiagnosticMessageChain {
82998289 let text = getLocaleSpecificMessage ( message ) ;
83008290
8301- if ( arguments . length > 2 ) {
8302- text = formatStringFromArgs ( text , arguments , 2 ) ;
8291+ if ( some ( args ) ) {
8292+ text = formatStringFromArgs ( text , args ) ;
83038293 }
83048294 return {
83058295 messageText : text ,
0 commit comments