@@ -23,6 +23,39 @@ import Foo from "Foo.ts";
2323export const Utils = { ok , trySync };
2424```
2525
26+ ## Functions
27+
28+ - ** Use arrow functions** - avoid the ` function ` keyword for consistency
29+ - ** Exception: function overloads** - TypeScript requires the ` function ` keyword for overloaded signatures
30+
31+ ``` ts
32+ // ✅ Good - Arrow function
33+ export const createUser = (data : UserData ): User => {
34+ // implementation
35+ };
36+
37+ // ✅ Good - Function overloads (requires function keyword)
38+ export function mapArray<T , U >(
39+ array : NonEmptyReadonlyArray <T >,
40+ mapper : (item : T ) => U ,
41+ ): NonEmptyReadonlyArray <U >;
42+ export function mapArray<T , U >(
43+ array : ReadonlyArray <T >,
44+ mapper : (item : T ) => U ,
45+ ): ReadonlyArray <U >;
46+ export function mapArray<T , U >(
47+ array : ReadonlyArray <T >,
48+ mapper : (item : T ) => U ,
49+ ): ReadonlyArray <U > {
50+ return array .map (mapper ) as ReadonlyArray <U >;
51+ }
52+
53+ // ❌ Avoid - function keyword without overloads
54+ export function createUser(data : UserData ): User {
55+ // implementation
56+ }
57+ ```
58+
2659## Immutability
2760
2861- ** Favor immutability** - use ` readonly ` properties and ` ReadonlyArray ` /` NonEmptyReadonlyArray `
0 commit comments