Skip to content

Commit 167f954

Browse files
authored
Handle undefined in indent helper (#38217)
* Handle undefined in indent helper Telemetry shows that it's called with undefined (probably `stderr` in an error scenario?). * Add undefined to parameter type
1 parent 466d0c0 commit 167f954

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/typingsInstaller/nodeTypingsInstaller.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ namespace ts.server.typingsInstaller {
246246
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation!, typingSafeListLocation!, typesMapLocation!, npmLocation, validateDefaultNpmLocation, /*throttleLimit*/5, log); // TODO: GH#18217
247247
installer.listen();
248248

249-
function indent(newline: string, str: string): string {
250-
return `${newline} ` + str.replace(/\r?\n/, `${newline} `);
249+
function indent(newline: string, str: string | undefined): string {
250+
return str && str.length
251+
? `${newline} ` + str.replace(/\r?\n/, `${newline} `)
252+
: "";
251253
}
252254
}

0 commit comments

Comments
 (0)