Skip to content

Commit bae1b9d

Browse files
committed
docs(skill): add TypeScript code examples to typescript-and-scss-rules reference
1 parent 4f454b5 commit bae1b9d

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

skills/react-container-presentation-component/references/typescript-and-scss-rules.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,36 @@
33
## TypeScript Rules
44

55
- Do not use `any`.
6+
7+
```ts
8+
// Bad
9+
const handler = (e: any) => {};
10+
11+
// Good
12+
const handler = (e: React.ChangeEvent<HTMLInputElement>) => {};
13+
```
14+
615
- Use `type` for props instead of `interface`.
16+
17+
```ts
18+
// Bad
19+
interface ButtonProps {
20+
label: string;
21+
}
22+
23+
// Good
24+
type ButtonProps = { label: string };
25+
```
26+
727
- Explicitly annotate function return types.
8-
- Prefer `@` alias imports and avoid deep relative imports.
28+
29+
```ts
30+
// Bad
31+
const getLabel = () => "hello";
32+
33+
// Good
34+
const getLabel = (): string => "hello";
35+
```
936

1037
## SCSS Rules
1138

0 commit comments

Comments
 (0)