Cast sys.bufferFrom results in cases where global buffer and sys copy of buffer mismatch

This commit is contained in:
Wesley Wigham 2020-02-19 17:02:30 -08:00
parent 5144330c98
commit 283bf999df
No known key found for this signature in database
GPG Key ID: D59F87F60C5400C9

View File

@ -211,7 +211,7 @@ namespace ts.server {
if (this.fd >= 0) {
const buf = sys.bufferFrom!(s);
// eslint-disable-next-line no-null/no-null
fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null!); // TODO: GH#18217
fs.writeSync(this.fd, buf as globalThis.Buffer, 0, buf.length, /*position*/ null!); // TODO: GH#18217
}
if (this.traceToConsole) {
console.warn(s);
@ -884,7 +884,7 @@ namespace ts.server {
}
// Override sys.write because fs.writeSync is not reliable on Node 4
sys.write = (s: string) => writeMessage(sys.bufferFrom!(s, "utf8"));
sys.write = (s: string) => writeMessage(sys.bufferFrom!(s, "utf8") as globalThis.Buffer);
sys.watchFile = (fileName, callback) => {
const watchedFile = pollingWatchedFileSet.addFile(fileName, callback);
return {