javascript - 条件始终为假,因为类型“字符串”在 Javascript 中没有重叠错误
问题描述
有一个变量,我正在读取用户的输入。例如:
let userName;
readUserNameFromUser(userName); // Consider this method will read the userName from user
if (userName === '') {
//Do Something;
}
在这种情况下userName === ''
,我收到此错误:
Condition is always false since types '(IFlagBase<any, boolean> & {type: "boolean", allowNo: boolean, default?: Default<boolean>}) | (IFlagBase<any, string> & {type: "option", helpValue?: string, default?: Default<any | undefined>, multiple: boolean, input: string[], options?: string[]} & {completion?: ICompletion})' and 'string' have no overlap
谁能帮我解决这个问题以及为什么会发生?
提前致谢。
解决方案
推荐阅读
- c++ - 文件系统:错误无法删除:输入/输出错误
- java - MyBatis: IllegalArgumentException: Mapped Statements 集合不包含值
- python-3.x - Pandas Python groupby多列 - 根据具有特定值的第一列按第2列中的值对行进行排序
- python - 无法使用 plotly 创建 HTML 文件
- node.js - Discord.js 组件
- python - 在 wxPython 中使用 TextCtrl 对 StaticText 进行分组
- python - Keras/Tensorflow 的 CTC 损失;形状不可配置
- python - 我有一个将 .dav 文件发送到我的 ftp 的 DVR 如何在我的 wordpress 站点中将其转换为 mp4?
- angular - 我无法导航到我的关于选项卡在 coursera 上的 Angular js 作业中。为什么?
- mysql - 更新时的Mysql未知列