Skip to content

Commit e6bdbb5

Browse files
committed
refactor: some changes in examples
1 parent 9e28674 commit e6bdbb5

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
${{ runner.os }}-
2525
2626
- name: 📥 Install dependencies
27-
run: npm install
27+
run: npm install --force
2828

2929
- name: 💅 Lint code style
3030
run: npm run lint

src/const-type-parameter/basic-example.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// Example with "as const"
33
export type User = { name: string; age: number };
44

5-
function getUserName<T extends User>(username: T): T["name"] {
6-
return username.name;
5+
function getUserName<T extends User>(user: T): T["name"] {
6+
return user.name;
77
}
88

99
const userName = getUserName({ name: "Isma", age: 31 } as const);
10-
// ^?
10+
// ^?
1111

1212
// Ejemplo const type parameter
13-
function getUserAge<const T extends User>(username: T): T["age"] {
14-
return username.age;
13+
function getUserAge<const T extends User>(user: T): T["age"] {
14+
return user.age;
1515
}
1616

1717
const userAge = getUserAge({ name: "Isma", age: 31 });
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EndpointPayload } from "./EndpointPayload";
22

33
export class CreateCoursePayload extends EndpointPayload {
4-
constructor(public readonly name: string, public readonly startDate: Date) {
4+
constructor(public readonly title: string, public readonly startDate: Date) {
55
super();
66
}
77
}

src/const-type-parameter/fetcher/fetcher.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ type Endpoint = {
1111
};
1212

1313
function setupFetcher<
14-
const GetEndpoint extends Readonly<Endpoint>,
15-
const PostEndpoint extends Readonly<Endpoint>
16-
>(endpoints: {
17-
get: ReadonlyArray<GetEndpoint>;
18-
post: ReadonlyArray<PostEndpoint>;
19-
}) {
14+
const GetEndpoint extends Endpoint,
15+
const PostEndpoint extends Endpoint
16+
>(endpoints: { get: GetEndpoint[]; post: PostEndpoint[] }) {
2017
const endpointNameToUrl = (method: keyof typeof endpoints, name: string) => {
2118
const t = endpoints[method];
2219

src/utility-types/derivated-types/groupByStatus.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ export interface Course {
55
status: "archived" | "active";
66
}
77

8-
export function groupByStatus(
9-
courses: Course[]
10-
): Record<CourseStatus, Course[]> {
8+
type GroupuedCoursesByStatus = Record<CourseStatus, Course[]>;
9+
10+
export function groupByStatus(courses: Course[]): GroupuedCoursesByStatus {
1111
const grouped: Record<CourseStatus, Course[]> = {
1212
active: [],
1313
archived: [],

0 commit comments

Comments
 (0)