typescript - Typescript const 名称和接口 - 如何实现?
问题描述
export declare const TerminalWidgetOptions; unique synbol;
export interface TerminalWidgetOptions {
endpoint: Endpoint.Options,
id: string,
caption: string,
label: string
destroyTermOnClose: boolean
}
使用此代码创建实现此接口的类时,出现错误:错误 TS2507:类型“唯一符号”不是构造函数类型。
我不明白为什么 TypeScript 看不到界面。
有人可以解释我吗?
解决方案
您是否尝试在定义和导出它之前声明它?
declare const TerminalWidgetOptions: unique symbol;
export interface TerminalWidgetOptions {
endpoint: Endpoint.Options;
id: string;
caption: string;
label: string;
destroyTermOnClose: boolean;
}
我参考了官方文档。