Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 类型脚本类型定义-接口引用类型,但用作值_Typescript - Fatal编程技术网

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[]
你可以看到区别