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
This commit is contained in:
Andrew Casey 2020-04-27 16:18:39 -07:00 committed by GitHub
parent 466d0c0ecb
commit 167f954ec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -246,7 +246,9 @@ namespace ts.server.typingsInstaller {
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation!, typingSafeListLocation!, typesMapLocation!, npmLocation, validateDefaultNpmLocation, /*throttleLimit*/5, log); // TODO: GH#18217
installer.listen();
function indent(newline: string, str: string): string {
return `${newline} ` + str.replace(/\r?\n/, `${newline} `);
function indent(newline: string, str: string | undefined): string {
return str && str.length
? `${newline} ` + str.replace(/\r?\n/, `${newline} `)
: "";
}
}