Use satisfies for type safety

This commit is contained in:
Saoud Rizwan
2024-09-22 21:27:41 -04:00
parent ae770a1c6a
commit fb24a2a796

View File

@@ -937,7 +937,7 @@ export class ClaudeDev {
tool: "editedExistingFile", tool: "editedExistingFile",
path: this.getReadablePath(relPath), path: this.getReadablePath(relPath),
diff: this.createPrettyPatch(relPath, originalContent, newContent), diff: this.createPrettyPatch(relPath, originalContent, newContent),
} as ClaudeSayTool) } satisfies ClaudeSayTool)
) )
} else { } else {
userResponse = await this.ask( userResponse = await this.ask(
@@ -946,7 +946,7 @@ export class ClaudeDev {
tool: "newFileCreated", tool: "newFileCreated",
path: this.getReadablePath(relPath), path: this.getReadablePath(relPath),
content: newContent, content: newContent,
} as ClaudeSayTool) } satisfies ClaudeSayTool)
) )
} }
const { response, text, images } = userResponse const { response, text, images } = userResponse
@@ -1111,7 +1111,7 @@ export class ClaudeDev {
tool: fileExists ? "editedExistingFile" : "newFileCreated", tool: fileExists ? "editedExistingFile" : "newFileCreated",
path: this.getReadablePath(relPath), path: this.getReadablePath(relPath),
diff: this.createPrettyPatch(relPath, normalizedNewContent, normalizedEditedContent), diff: this.createPrettyPatch(relPath, normalizedNewContent, normalizedEditedContent),
} as ClaudeSayTool) } satisfies ClaudeSayTool)
) )
return [ return [
false, false,
@@ -1220,7 +1220,7 @@ export class ClaudeDev {
tool: "readFile", tool: "readFile",
path: this.getReadablePath(relPath), path: this.getReadablePath(relPath),
content: absolutePath, content: absolutePath,
} as ClaudeSayTool) } satisfies ClaudeSayTool)
if (this.alwaysAllowReadOnly) { if (this.alwaysAllowReadOnly) {
await this.say("tool", message) await this.say("tool", message)
} else { } else {
@@ -1264,7 +1264,7 @@ export class ClaudeDev {
tool: recursive ? "listFilesRecursive" : "listFilesTopLevel", tool: recursive ? "listFilesRecursive" : "listFilesTopLevel",
path: this.getReadablePath(relDirPath), path: this.getReadablePath(relDirPath),
content: result, content: result,
} as ClaudeSayTool) } satisfies ClaudeSayTool)
if (this.alwaysAllowReadOnly) { if (this.alwaysAllowReadOnly) {
await this.say("tool", message) await this.say("tool", message)
} else { } else {
@@ -1368,7 +1368,7 @@ export class ClaudeDev {
tool: "listCodeDefinitionNames", tool: "listCodeDefinitionNames",
path: this.getReadablePath(relDirPath), path: this.getReadablePath(relDirPath),
content: result, content: result,
} as ClaudeSayTool) } satisfies ClaudeSayTool)
if (this.alwaysAllowReadOnly) { if (this.alwaysAllowReadOnly) {
await this.say("tool", message) await this.say("tool", message)
} else { } else {
@@ -1418,7 +1418,7 @@ export class ClaudeDev {
regex: regex, regex: regex,
filePattern: filePattern, filePattern: filePattern,
content: results, content: results,
} as ClaudeSayTool) } satisfies ClaudeSayTool)
if (this.alwaysAllowReadOnly) { if (this.alwaysAllowReadOnly) {
await this.say("tool", message) await this.say("tool", message)