This theme is from |

guangzan

园龄:6年5个月粉丝:676关注:333

2020-07-07 15:54阅读: 407评论: 0推荐: 0

ts 常用配置

这里记录一些常用的 ts config。

strictNullChecks

"strictNullChecks": true 严格区分 undefined 和 null

let weight: number | undefined
weight = undefined
// ?相当于 string | undefined
function getPeople(params: string) {
  return name || ''
}
// getPeople(null) X

moduleResolution

"moduleResolution": "node" 首先取 nodemodules 寻找模块

import _ from 'lodash'

esModuleInterop

"esModuleInterop": true

自动检测模块类型 commonjs | esmodule,与编译有关,若导出没有 default 自动加上 default

noImplicitAny

"noImplicitAny": true 不允许存在隐式的 any 类型

const student = []
const key = 'name'
// student[key] = 'zhangsan' X

本文作者:guangzan

本文链接:https://www.cnblogs.com/guangzan/p/13261306.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   guangzan  阅读(407)  评论(0编辑  收藏  举报
评论
收藏
关注
推荐
深色
回顶
收起
点击右上角即可分享
微信分享提示