interface Article {
filename: string
title: string
date: string
}
const articles: Article[] = [
{
filename: 'article1',
title: 'first article',
date: '2021-04-13T18:10:40.578Z'
},
{
filename: 'article2',
title: 'second article',
date: '2021-04-13T19:32:39.556Z'
}
]
// 从 articles 的 filename 字段提取类型
// 结果 => type ArticleFilename = 'article1' | 'article2'
type ArticleFilename = ???
1
codehz 2021-04-15 02:18:29 +08:00 4
|
3
orzfly 2021-04-15 10:22:59 +08:00
|
5
ryougifujino 2021-04-15 19:25:06 +08:00
学习了,一开始还以为不行。
|