0
내 목표는 K
에있는 모든 키의 "정확한 개체 형식"인 Entities
형식을 만드는 것입니다.여러 인덱서는 오류가 허용되지 않지만 인덱서가 아닙니다.
K
은 다음과 같습니다
type SocialEntity = Article | Thumb | Comment | Displayname | Helpful;
type SocialEntityKind = 'articles' | 'thumbs' | 'comments' | 'displaynames' | 'helpfuls';
const K: {[key: SocialEntityKind]: SocialEntityKind} = { // short for SOCIAL_ENTITY_KIND
articles: 'articles',
thumbs: 'thumbs',
comments: 'comments',
displaynames: 'displaynames',
helpfuls: 'helpfuls'
}
가 지금은
[key: typeof K.*]
을 설정하지만이 인덱서을 고려했습니다.
이 작업을 수행 할 수있는 쉽고 올바른 방법이 있나요 : 여기
type Entities = {|
[key: typeof K.articles]: {
[key: ArticleId]: Article
},
[key: typeof K.thumbs]: {
[key: ThumbId]: Thumb
},
[key: typeof K.comments]: {
[key: CommentId]: Comment
},
[key: typeof K.displaynames]: {
[key: DisplaynameId]: Displayname
},
[key: typeof K.helpfuls]: {
[key: HelpfulId]: Helpful
}
|}
오류의 스크린 샷이다?
Drats, thanks logan. – Noitidart