Skip to content

Commit 119a945

Browse files
committed
Handle stricter 1.94 type checking wrt Buffer vs Uint8Array
1 parent df9d264 commit 119a945

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/commands/compile.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ export async function checkChangedOnServer(file: CurrentTextFile | CurrentBinary
6969
? false
7070
: (content as string[]).every((line, index) => line.trim() == (fileContent[index] || "").trim());
7171
} else {
72-
sameContent = force ? false : Buffer.compare(content as Buffer, file.content) === 0;
72+
sameContent = force
73+
? false
74+
: Buffer.compare(content as unknown as Uint8Array, file.content as unknown as Uint8Array) === 0;
7375
}
7476
const mtime =
7577
force || sameContent ? serverTime : Math.max((await vscode.workspace.fs.stat(file.uri)).mtime, serverTime);
@@ -243,7 +245,7 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
243245
const content = await api.getDoc(file.name).then((data) => data.result.content);
244246
await vscode.workspace.fs.writeFile(
245247
file.uri,
246-
Buffer.isBuffer(content) ? content : new TextEncoder().encode(content.join("\n"))
248+
Buffer.isBuffer(content) ? (content as unknown as Uint8Array) : new TextEncoder().encode(content.join("\n"))
247249
);
248250
} else if (filesystemSchemas.includes(file.uri.scheme)) {
249251
fileSystemProvider.fireFileChanged(file.uri);

src/providers/FileSystemProvider/FileSystemProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
398398

399399
public writeFile(
400400
uri: vscode.Uri,
401-
content: Buffer,
401+
content: Uint8Array,
402402
options: {
403403
create: boolean;
404404
overwrite: boolean;
@@ -452,7 +452,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
452452
}
453453
// File doesn't exist on the server, and we are allowed to create it.
454454
// Create content (typically a stub, unless the write-phase of a copy operation).
455-
const newContent = generateFileContent(uri, fileName, content);
455+
const newContent = generateFileContent(uri, fileName, content as unknown as Buffer);
456456

457457
// Write it to the server
458458
return api

0 commit comments

Comments
 (0)