Typescript 类型脚本类型定义-接口引用类型,但用作值
我有以下代码:Typescript 类型脚本类型定义-接口引用类型,但用作值,typescript,Typescript,我有以下代码: export interface Chapter { title: string, path: string } export type TableOfContents: Chapter[] 但我得到了以下错误: [ts]“Chapter”仅指类型,但用作值 在这里[2693] 我想导出接口章节,然后导出类型TableOfContents,它是一个章节数组 我做错了什么?要创建类型别名,必须使用=而不是: export type TableOfContents
export interface Chapter {
title: string,
path: string
}
export type TableOfContents: Chapter[]
但我得到了以下错误:
[ts]“Chapter”仅指类型,但用作值
在这里[2693]
我想导出接口章节,然后导出类型TableOfContents,它是一个章节数组
我做错了什么?要创建类型别名,必须使用
=
而不是:
export type TableOfContents = Chapter[]
您可以看到差异。要创建类型别名,您必须使用
=
而不是:
export type TableOfContents = Chapter[]
你可以看到区别