Prompt
Follow consistent naming conventions in TypeScript to improve code clarity, type safety, and developer experience:
- Capitalize types and interfaces: All type and interface names should start with an uppercase letter.
// Incorrect type chainTypeName = "stuff" | "map_reduce"; // Correct type ChainTypeName = "stuff" | "map_reduce"; - Use
unknowninstead ofany: When the type is truly not known, preferunknownoveranyfor better type safety.// Incorrect - too permissive function isBuiltinTool(tool: any) // Correct - safer typing function isBuiltinTool(tool: unknown) - Prefer type literals over strings for constrained values to improve developer experience and catch errors at compile time.
// Incorrect function createLoader(mode: string) // Correct type SearchMode = "subreddit" | "username"; function createLoader(mode: SearchMode) - Use visibility modifiers instead of naming conventions for private/protected members:
// Incorrect class GraphQLClientTool { _endpoint: string; } // Correct class GraphQLClientTool { private endpoint: string; } - Standardize parameter naming across similar components (e.g., use
modelinstead ofmodelNamefor consistency):// Standardized interface EmbeddingsParams { model: string; // Not modelName } - Improve type precision when appropriate to enhance developer experience:
// Less precise loaders: { [extension: string]: (path: string) => Loader } // More precise loaders: { [extension: `.${string}`]: (path: string) => Loader }