Skip to content

Handle stricter 1.94 type checking wrt Buffer vs Uint8Array #1439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export async function checkChangedOnServer(file: CurrentTextFile | CurrentBinary
? false
: (content as string[]).every((line, index) => line.trim() == (fileContent[index] || "").trim());
} else {
sameContent = force ? false : Buffer.compare(content as Buffer, file.content) === 0;
sameContent = force
? false
: Buffer.compare(content as unknown as Uint8Array, file.content as unknown as Uint8Array) === 0;
}
const mtime =
force || sameContent ? serverTime : Math.max((await vscode.workspace.fs.stat(file.uri)).mtime, serverTime);
Expand Down Expand Up @@ -243,7 +245,7 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
const content = await api.getDoc(file.name).then((data) => data.result.content);
await vscode.workspace.fs.writeFile(
file.uri,
Buffer.isBuffer(content) ? content : new TextEncoder().encode(content.join("\n"))
Buffer.isBuffer(content) ? (content as unknown as Uint8Array) : new TextEncoder().encode(content.join("\n"))
);
} else if (filesystemSchemas.includes(file.uri.scheme)) {
fileSystemProvider.fireFileChanged(file.uri);
Expand Down
4 changes: 2 additions & 2 deletions src/providers/FileSystemProvider/FileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {

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

// Write it to the server
return api
Expand Down