(Component: React.ComponentType) => (props: T) => (
+
+ }>
+
+
+
+);
\ No newline at end of file
diff --git a/typescript/template/src/pages/counter/ui.module.css b/typescript/template/src/pages/counter/styles.module.css
similarity index 100%
rename from typescript/template/src/pages/counter/ui.module.css
rename to typescript/template/src/pages/counter/styles.module.css
diff --git a/typescript/template/src/pages/counter/ui.tsx b/typescript/template/src/pages/counter/ui.tsx
index 87fb2ff..40aaca6 100644
--- a/typescript/template/src/pages/counter/ui.tsx
+++ b/typescript/template/src/pages/counter/ui.tsx
@@ -1,21 +1,19 @@
-import { useState } from 'react';
+import React from 'react';
import { Button } from 'shared/ui/button';
-import styles from './ui.module.css';
+import { useCounter } from './model';
+import styles from './styles.module.css';
-export const CounterPage = () => {
- const [counter, setCounter] = useState(0);
+export const CounterPage: React.FC = () => {
+ const { counter, increment, decrement } = useCounter(0);
return (
Counter {counter}
-
);
};
diff --git a/typescript/template/src/pages/router/public-routes.tsx b/typescript/template/src/pages/router/public-routes.tsx
index 428d67a..7fe3e98 100644
--- a/typescript/template/src/pages/router/public-routes.tsx
+++ b/typescript/template/src/pages/router/public-routes.tsx
@@ -1,9 +1,5 @@
-import { FC } from 'react';
+import React from 'react';
import { useRoutes } from 'react-router-dom';
import { publicRoutes } from './routes';
-export const PublicRoutes: FC = () => {
- const routes = useRoutes(publicRoutes);
-
- return routes;
-};
+export const PublicRoutes: React.FC = () => useRoutes(publicRoutes)
diff --git a/typescript/template/src/shared/lib/fp/compose.js b/typescript/template/src/shared/lib/fp/compose.js
deleted file mode 100644
index 7d23e4f..0000000
--- a/typescript/template/src/shared/lib/fp/compose.js
+++ /dev/null
@@ -1,10 +0,0 @@
-export function compose(...funcs) {
- if (funcs.length === 0) return;
- if (funcs.length === 1) return funcs[0];
-
- return funcs.reduce(
- (a, b) =>
- (...args) =>
- a(b(...args))
- );
-}
diff --git a/typescript/template/src/shared/lib/fp/compose.ts b/typescript/template/src/shared/lib/fp/compose.ts
new file mode 100644
index 0000000..80e56ba
--- /dev/null
+++ b/typescript/template/src/shared/lib/fp/compose.ts
@@ -0,0 +1,44 @@
+type Func = (...a: T) => R
+
+export default function compose(): (a: R) => R
+export default function compose(f: F): F
+export default function compose(
+ f1: (a: A) => R,
+ f2: Func
+): Func
+
+export default function compose(
+ f1: (b: B) => R,
+ f2: (a: A) => B,
+ f3: Func
+): Func
+
+export default function compose(
+ f1: (c: C) => R,
+ f2: (b: B) => C,
+ f3: (a: A) => B,
+ f4: Func
+): Func
+
+export default function compose(
+ f1: (a: any) => R,
+ ...funcs: Function[]
+): (...args: any[]) => R
+
+export default function compose(...funcs: Function[]): (...args: any[]) => R
+
+export default function compose(...funcs: Function[]) {
+ if (funcs.length === 0) {
+ return (arg: T) => arg
+ }
+
+ if (funcs.length === 1) {
+ return funcs[0]
+ }
+
+ return funcs.reduce(
+ (a, b) =>
+ (...args: any) =>
+ a(b(...args))
+ )
+}
diff --git a/typescript/template/src/shared/lib/fp/index.js b/typescript/template/src/shared/lib/fp/index.js
deleted file mode 100644
index f03e6f5..0000000
--- a/typescript/template/src/shared/lib/fp/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export { compose } from './compose';
diff --git a/typescript/template/src/shared/lib/fp/index.ts b/typescript/template/src/shared/lib/fp/index.ts
new file mode 100644
index 0000000..a0fcc00
--- /dev/null
+++ b/typescript/template/src/shared/lib/fp/index.ts
@@ -0,0 +1 @@
+export { default as compose } from './compose';
diff --git a/typescript/template/src/shared/ui/Loader/index.ts b/typescript/template/src/shared/ui/Loader/index.ts
deleted file mode 100644
index 0223844..0000000
--- a/typescript/template/src/shared/ui/Loader/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { Loader } from './loader';
diff --git a/typescript/template/src/shared/ui/button/button.tsx b/typescript/template/src/shared/ui/button/button.tsx
index e1c14e7..a543aef 100644
--- a/typescript/template/src/shared/ui/button/button.tsx
+++ b/typescript/template/src/shared/ui/button/button.tsx
@@ -1,19 +1,17 @@
-import { FC, MouseEventHandler } from 'react';
+import React from 'react';
import styles from './button.module.css';
interface Props {
className?: string;
- onClick?: MouseEventHandler;
+ onClick?: React.MouseEventHandler;
}
-export const Button: FC = ({ className, children, onClick }) => {
- return (
-
- {children}
-
- );
-};
+export const Button: React.FC = ({ className, children, onClick }) => (
+
+ {children}
+
+);
diff --git a/typescript/template/src/shared/ui/loader/index.tsx b/typescript/template/src/shared/ui/loader/index.tsx
new file mode 100644
index 0000000..12adaf9
--- /dev/null
+++ b/typescript/template/src/shared/ui/loader/index.tsx
@@ -0,0 +1,5 @@
+import React from 'react';
+
+export const Loader: React.FC = () => (
+ loading...
+);
\ No newline at end of file
diff --git a/typescript/template/src/shared/ui/loader/loader.tsx b/typescript/template/src/shared/ui/loader/loader.tsx
deleted file mode 100644
index abf5760..0000000
--- a/typescript/template/src/shared/ui/loader/loader.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export const Loader = () => {
- return loading...
;
-};