Follow consistent naming conventions in TypeScript to improve code clarity, type safety, and developer experience: 1. **Capitalize types and interfaces**: All type and interface names should start with an uppercase letter.
Follow consistent naming conventions in TypeScript to improve code clarity, type safety, and developer experience:
// Incorrect
type chainTypeName = "stuff" | "map_reduce";
// Correct
type ChainTypeName = "stuff" | "map_reduce";
unknown
instead of any
: When the type is truly not known, prefer unknown
over any
for better type safety.
// Incorrect - too permissive
function isBuiltinTool(tool: any)
// Correct - safer typing
function isBuiltinTool(tool: unknown)
// Incorrect
function createLoader(mode: string)
// Correct
type SearchMode = "subreddit" | "username";
function createLoader(mode: SearchMode)
// Incorrect
class GraphQLClientTool {
_endpoint: string;
}
// Correct
class GraphQLClientTool {
private endpoint: string;
}
model
instead of modelName
for consistency):
// Standardized
interface EmbeddingsParams {
model: string; // Not modelName
}
// Less precise
loaders: { [extension: string]: (path: string) => Loader }
// More precise
loaders: { [extension: `.${string}`]: (path: string) => Loader }
Enter the URL of a public GitHub repository