标签: typescript
我有以下代码:
export interface Chapter { title: string, path: string } export type TableOfContents: Chapter[]
但是我遇到以下错误:
[ts]“章节”仅指类型,但被用作值 这里。 [2693]
我想导出接口Chapter,然后导出TableOfContents类型,它是各章的数组。
我在做什么错了?
答案 0 :(得分:4)
要创建类型别名,您必须使用=而不是:。
=
:
export type TableOfContents = Chapter[]
您可以看到区别in the TypeScript playground。