TypeScript语法:someObject!.prop

时间:2018-03-22 11:57:37

标签: angular typescript syntax

我正在观看Github上的Angular问题,我遇到了有趣的.ts语法,我以前从未见过。我试图理解它,并检查它在实践中是如何工作的,但是......我不明白。

Link to script on Github

此剧本由Angular团队的某人审核并被普遍接受。

语法看起来简单而且很奇怪,在代码中出现了几次:

import React, { Component } from 'react'

const patients = [
  {
    "profileId": "b4KEOLTxPcu73VVc",
    "firstName": "John",
    "lastName": "Doe",
    "birthDate": "1994-10-10T04:00:00.000Z",
    "gender": "M",
    "email": "john@doe.com",
    "provider": "ckdj8g9isusjx765",
    "__v": 0,
    "verified": false,
    "status": "ARCHIVED",
    "lastActive": "2018-03-13T02:17:38.391Z",
    "profileCreatedAt": "2018-03-13T02:17:38.391Z"
  }
]

export default class Patients extends Component {
  constructor(props) {
    super(props)
  }

  render() {
    return (
      <div className="patients">
        <PatientsTabNavigation />
        <PatientsSortableTable  patients={patients} />
      </div>
    )
  }

看起来有人在检查是否 const outlet = context !.outlet !; this.deactivateRouteAndItsChildren(v, contexts !.getContext(k)) this.shouldRunGuardsAndResolvers( curr, future, future.routeConfig !.runGuardsAndResolvers) 存在,但如果不存在,则返回undefined。 嗯,对我来说它看起来像只写someObj.someProp是不是吗?

有人可以解释我的用法吗?

0 个答案:

没有答案