小编lea*_*mer的帖子

我无法使从接口实现的类字段私有,也无法使接口字段私有

我在界面上有这个字段:

// Stores the to views folder
VIEW_PATH: string;
// Stores BrowserWindows with respective view  
browserWindows: [string, BrowserWindow | null][];
Run Code Online (Sandbox Code Playgroud)

当我在类中实现这些字段并尝试将它们设置为私有时,出现以下错误:

Class 'WindowHandler' incorrectly implements interface 'IWindowHandler'.
  Property 'VIEW_PATH' is private in type 'WindowHandler' but not in type 'IWindowHandler'.ts(2420)
Run Code Online (Sandbox Code Playgroud)

当我尝试将接口字段设置为私有时:

'private' modifier cannot appear on a type member.ts(1070)
Run Code Online (Sandbox Code Playgroud)

interface class typescript

7
推荐指数
1
解决办法
3470
查看次数

标签 统计

class ×1

interface ×1

typescript ×1