Generics(2) 에서 배운것을 응용하여 첫시간에 배운 객체의 동적할당 부분을 구현하고 싶습니다.
374
0
interface Post{
id:number
title:string
[key:string]:unknown
}
const post:Post={
id:1,
title: 'post 1'
}
post['description']='description'
post['pages']=100
항상들어가는 id:number, title:string 속성을 제외한 동적할당 부분 post['description']='description', post['pages']=100을 [key: string]: number| string 으로 구현하려고 하는데 자료구조상 구현이 불가능할까요?
interface Post<T extends {id: number, title: string}> {
id:number
title:string
[key:string]:T
}
const post:Post<string | number>={
id:1,
title: 'post 1'
}
post['description']='description'
post['pages']=100
답변 0
비전공 국비수료생이 볼 수 있을까요?
0
381
1
로드맵으로 프론트엔드 전향이 가능할까요?
0
397
1
요즘시장에 MERN스택으로 개발하는 프로젝트가 많이 있는지 궁금합니다.
0
441
1
이번에 새로 개강한강좌에대해서 문의요
1
237
1
서버공부 (Java spring)
0
425
0
완강 후 결과물 뒤 커버가 겹쳐서 보이는 경우
0
337
0
여러개의 강의 중 어떤걸 먼저 들어야하나요?
1
390
1
업데이트로 인해, Adroid 설정부분이 조금 다릅니다.
1
436
1
질문이 아니라서 여기에 올립니다.
0
365
1
안녕하세요 질문있습니다!
0
403
1
현업에서 백엔드로는 보통 뭐를 사용하나요?
1
389
1
백엔드 배포 질문
0
456
0





