【文件属性】:
文件名称:optional-chain:TypeTypeScript中的可选链接实现
文件大小:51KB
文件格式:ZIP
更新时间:2021-05-17 08:58:13
typescript option-type optional-chaining TypeScript
可选链
TypeScript中的可选链接实现。 使用
要求
该库需要TS 2.8+版本才能使用
安装
npm install optional-chain
用法
import { optional } from "optional-chain" ;
type User = {
name ?: {
first : string
}
}
const user : User = getUser ( ) ; // { name: null }
const optionalUser = optional ( user ) ;
optionalUser . k ( "name" ) . k ( "first" ) . get ( ) ; // undefined, does not throw an exception.
原料药
API下的optional-chain库导出。
op
【文件预览】:
optional-chain-master
----.travis.yml(113B)
----example()
--------package.json(306B)
--------package-lock.json(400B)
--------src()
--------tsconfig.json(412B)
----package.json(1017B)
----__tests__()
--------index.ts(4KB)
----.github()
--------workflows()
----greenkeeper.json(128B)
----LICENSE(1KB)
----package-lock.json(188KB)
----src()
--------index.ts(1KB)
----tsconfig.json(412B)
----.gitignore(26B)
----README.md(3KB)