Skip to content

complete/week1 - #13

Merged
InSeong-So merged 1 commit into
pagers-org:june6723from
june6723:main
Aug 19, 2022
Merged

complete/week1#13
InSeong-So merged 1 commit into
pagers-org:june6723from
june6723:main

Conversation

@june6723

Copy link
Copy Markdown

No description provided.

Comment thread 1week/assignment/01.ts
Comment on lines +5 to +6
type Name = string | { first: number, last: string}
type EventDate = string | Date | null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 유니온이 많거나 객체 형태의 타입은 타입 별칭으로 분리해주는 게 좋죠! 멋있어요😊

Comment thread 1week/assignment/02.ts
Comment on lines 167 to +168

const YOURE_PALETTE_THEME = {};
type ValueOf<T> = T[keyof T];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 오!! 이런 유틸리티 타입을 만드셔서 아래의 상수를 작성해주셨네요! 잘 봤습니다👏

Comment thread 1week/assignment/03.ts
Comment on lines 9 to 11
userName: string;
userRole: 'normal' | 'vip' | 'admin';
userRole: UserRole;
password: string;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리터럴 타입을 타입 별칭으로 분리!! 아주 좋습니다!
userRole이 유연해지려면.... 제너릭을 활용하면 어떨까요?

Comment thread 1week/assignment/05.ts
Comment on lines +19 to +21
type DeepReadonly<T> = {
readonly [key in keyof T]: DeepReadonly<T[key]>
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인덱스 시그니처의 좋은 활용 예죠! 아주 좋습니다🙌
저도 리뷰를 받은 부분인데, 추후에는 고도화를 할 수 있는 부분이 많아요.
null, undefined 같은 타입이 들어오면 readonly가 아니게 되거든요!

Comment thread 1week/assignment/04.ts
Comment on lines +8 to +9
class List<T> {
private items: T[] = [];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread 1week/assignment/04.ts
Comment on lines +19 to +21
remove(index: number) {
return this.items.splice(index, 1);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제거된 값을 return 해주셨네요! 좋습니다🙌

Comment thread 1week/assignment/06.ts
Comment on lines +11 to +16
const savingAction: Action = {
type: 'saving',
payload: ['Apple', 'Banana', 'Strawberry'],
};

type SavedAction = {
type: 'saved';
};

const savedAction: SavedAction = {
const savedAction: Action = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

타입을 사전에 정의해서 상수를 제한했네요! 좋습니다 ㅎㅎ
문제 의도와는 달랐지만 타입을 정의하는 형태가 보기 좋아요!

Comment thread 1week/assignment/07.ts
Comment on lines +5 to 8
class Cylinder {
radius = 1;
height = 1;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 코드는 아래와 같이 단축된답니다!

class Cylinder {
  consturctor(public radius:number, public height:number){}
}

Comment thread 1week/assignment/09.ts
Comment on lines +5 to +11
type Parameter = string | number | {
x: Parameter;
length: number;
mop: (callback: (x: Parameter)=> string) => string[]
}

function prettyPrint(x: Parameter): string {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오....! 타입을 이렇게 프로퍼티로 제한해주셨네요! 정말 신선합니다ㅎㅎ
잘 보고 가요! 다만 객체나 function 타입 등이 들어오면... 어떻게 될까요? 😳

Comment thread 1week/assignment/10.ts
Comment on lines +5 to +16
const never = `
TS에서 가질 수 있는 가장 작은 집합
`;

const unknown = `
모든 타입을 할당 받을 수 있으나 any와 다른 것은 unknown 타입으로 선언된 변수는 any를 제외한 다른 타입으로 선언된 변수에 할당될 수 없다는 것
`

const any = `
모든 타입을 할당 받을 수 있는 TS의 치트키.
하지만 JS프로젝트를 TS로 마이그레이션 할때만 사용하도록 하고 실제 협업에서는 사용을 지양하자.
`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

백틱으로 정리!! 이것도 새로운 코드라 재밌었습니다🙌

@InSeong-So
InSeong-So changed the base branch from main to june6723 August 19, 2022 15:06
@InSeong-So
InSeong-So merged commit a5cfc26 into pagers-org:june6723 Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants