TypeScript中的interface vs Type
做TS项目,经常会用到interface,和type。一般类型定义我会使用interface,而简单且是约束值的会使用type,比如
type username='bob'|'kelly'
,另外我会通过tslint配置中的Use an interface instead of a type literal.
来进行束缚。BUT,准确的差异在哪,到底该怎么用呢,没法闹,这里调查且总结一番。
官网怎么说
As we mentioned, type aliases can act sort of like interfaces; however, there are some subtle differences.
One difference is that interfaces create a new name that is used everywhere. Type aliases don’t create a new name
Because an ideal property of software is being open to extension, you should always use an interface over a type alias if possible.
On the other hand, if you can’t express some shape with an interface and you need to use a union or tuple type, type aliases are usually the way to go.
官网介绍戳这里
划重点
JetBrains IDE常用插件
Jetbrains系列产品用起来确实高效。从本身IDE的功能强大,到快捷键的丰富支持,再到插件生态的丰富等等。一切铸就了它无愧是当前最强IDE。
持续更新
这里列出我在用的几款插件
Plugins
String Manipulation
React调试-插件篇
React组件调试,除了万能油console之外,可以利用react-devtools及Redux DevTools辅助工具。因为Team总会来新人,为了快速入门,这里小结一番。
插件安装需要上Chrome商店,如果还不会科学上网,上不了谷歌。我的天,恳请您换职业。当然,b本着人道主义关怀,还是说下怎么解决在不能上谷歌的情况下如何插件安装
获取插件
https://crxextractor.com/
输入,插件商店地址,点击即可下载crx。拖拽到chrome中即可安装。
一键连接Cisco AnyConnect Secure Mobility Client
因为最近众所周知的原因,上不了外网了,so开始使用公司VPN,但是公司VPN连接起来总是很费时间。步骤繁琐,于是考虑如何解决。
公司的一封邮件给了很大的帮助,测试成功,这里我也总结一番。
繁琐的启动步骤
- 启动Cisco AnyConnect Secure Mobility Client
- 输入账户密码
- 选择手机短信验证码校验
- 手机查收短信验证码
- 客户端输入验证码
- 点击确定
如何自动化呢
安装oath-toolkit
1
$ brew install oath-toolkit
编写shell脚本
比如叫vpn.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14#!/bin/bash
killall 'Cisco AnyConnect Secure Mobility Client' 2>/dev/ null
/opt/cisco/anyconnect/bin/vpn disconnect >/dev/null
code=`oathtool --totp -b **secret_key**`
/opt/cisco/anyconnect/bin/vpn -s connect $1.company.vpn.com << EOF | sed 's/Password: .*/Password: ********/g'
**username**
**password**
**second_authentication_method_index**
$code
EOF
open -g '/Applications/Cisco/Cisco AnyConnect Secure Mobility Client.app'填写变量信息
- secret_key为我们vpn登陆认证的secret key,比如我司用的Okta Verify,则登陆网站,在修改密码=>Extra Verification=>Okta Verify Mobile App=>Setup=>Next=>Problems scaning barcode=>找到Secret Key,记住这个key.点击返回可继续增加手机App校验。记住两者不影响
- username即VPN用户名
- password即VPN用户密码
- second_authentication_method_index指的是当我们VPN登陆时,选择的校验类型,选择对应的即可,我们既然选择了Secret key,找到对应的序号填入即可
到此,最麻烦的手机校验码通过这个secret key搞到了
shell增加执行权限
1
chmod +x vpn.sh
执行脚本
1
2./vpn.sh bj