简体   繁体   English

获取 tslint 错误:`解析错误:预期表达式`

[英]Getting tslint error: `Parsing error: Expression expected`

Can someone shed me some light on this?有人可以让我对此有所了解吗?

I'm getting Failed to compile. Parsing error: Expression expectedFailed to compile. Parsing error: Expression expected Failed to compile. Parsing error: Expression expected with this line - Failed to compile. Parsing error: Expression expected此行Failed to compile. Parsing error: Expression expected -

isLogViewVisible: dashboard?.logView !== null where isLogViewVisible is boolean isLogViewVisible: dashboard?.logView !== null其中isLogViewVisibleboolean

interface IDashboard {
  logView: ILogView
}

interface ILogView {
  history: string
}

let dashboard: IDashboard | null
let logView: ILogView | null


const someVariable = {
  isLogViewVisible: dashboard?.logView !== null
}

: is for type information, use = for assignment (and === for equality): :用于类型信息,使用=进行赋值(和===用于相等):

isLogViewVisible = state.dashboard?.logView === null

or if you want to make the type explicit (useless here, it is trivially inferred):或者如果你想让类型显式(这里没用,它是微不足道的推断):

const isLogViewVisible: boolean = state.dashboard?.logView === null

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM