Adds type safety to process event handlers
Specifies the types for data and close events in process handlers. This improves code clarity and maintainability by ensuring that the data received from stdout and stderr streams is treated as a Buffer, and the close event receives a number or null for the exit code.
This commit is contained in:
3 files changed
+15
-15
No files matched your search
@@ -102,15 +102,15 @@ export class obsidianTypstPDFExport extends Plugin {
|
||||
let output = '';
|
||||
let error = '';
|
||||
|
||||
typstProcess.stdout?.on('data', (data) => {
|
||||
typstProcess.stdout?.on('data', (data: Buffer) => {
|
||||
output += data.toString();
|
||||
});
|
||||
|
||||
typstProcess.stderr?.on('data', (data) => {
|
||||
typstProcess.stderr?.on('data', (data: Buffer) => {
|
||||
error += data.toString();
|
||||
});
|
||||
|
||||
typstProcess.on('close', (code) => {
|
||||
typstProcess.on('close', (code: number | null) => {
|
||||
if (code === 0) {
|
||||
resolve(output);
|
||||
} else {
|
||||
@@ -118,7 +118,7 @@ export class obsidianTypstPDFExport extends Plugin {
|
||||
}
|
||||
});
|
||||
|
||||
typstProcess.on('error', (err) => {
|
||||
typstProcess.on('error', (err: Error) => {
|
||||
reject(new Error(`Failed to spawn typst process: ${err.message}`));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user