String Builder Optimization (ARCH3071)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key typescript.performance.string-builder-optimization · Severity info · Category performance
Concatenating many literals or operands with + in a single expression hurts readability and can be expressed more efficiently with a template literal or join.
Incorrect
Section titled “Incorrect”function row(a: string, b: string, c: string, d: string): string { return "<tr><td>" + a + "</td><td>" + b + "</td><td>" + c + "</td><td>" + d + "</td></tr>";}Correct
Section titled “Correct”function row(a: string, b: string, c: string, d: string): string { return `<tr><td>${a}</td><td>${b}</td><td>${c}</td><td>${d}</td></tr>`;}Replace long concatenation chains with a template literal or join.