Choose names that clearly communicate the semantic purpose and behavior of code elements. Variable and function names should precisely reflect their role, return type, and intended usage.
Choose names that clearly communicate the semantic purpose and behavior of code elements. Variable and function names should precisely reflect their role, return type, and intended usage.
Key guidelines:
Example:
// Poor naming
function isGlobalType(checker: TypeChecker, symbol: Symbol) {
return checker.resolveName(symbol.name, undefined, SymbolFlags.Type, false);
}
// Better naming - reflects actual behavior
function canResolveTypeGlobally(checker: TypeChecker, typeName: string) {
return checker.resolveName(typeName, undefined, SymbolFlags.Type, false);
}
// Poor naming - reusing variable
let initializer = getCandidateVariableDeclarationInitializer(declaration);
if (initializer) { ... }
initializer = getDestructuredInitializer(declaration);
// Better naming - distinct purposes
let directInit = getCandidateVariableDeclarationInitializer(declaration);
if (directInit) { ... }
let destructuredInit = getDestructuredInitializer(declaration);
Enter the URL of a public GitHub repository