javascript - 流程无法决定在联合类型上选择哪种情况
问题描述
当我尝试联合元组有一些长度的数组时,我得到了错误
看看这个工作示例,其中每种类型都有不同的长度。例子。(UPD:将流程版本更改为 0.71)
但是当我尝试添加一些长度流的类型时无法解决它。例子。
type Step<T> = T | [T] | [T, Object];
type S3 = [Step<'Z'>]
type S4 = [Step<'X'>]
type S = S3 | S4
let a6: S = ['Z']
let a7: S = [['Z']]
错误:
11: let a7: S = [['Z']]
^ Could not decide which case to select. Since case 1 [1] may work but if it
doesn't case 2 [2] looks promising too. To fix add a type annotation to array literal [3].
References:
8: type S = S3 | S4
^ [1]
8: type S = S3 | S4
^ [2]
11: let a7: S = [['Z']]
^ [3]
我怎么解决这个问题?
解决方案
推荐阅读
- python - 关于如何使用 ffmpeg/image2pipe 指定 GPX 动画视频长度的建议
- macros - 调整 Common Lisp “pushnew” 以返回成功/失败
- ruby - 如何配置 net-ssh 以便我可以通过 ssh 隧道使用 rest-client 获取数据?
- ansible - 将输出写入本地文件并从 Ansible for Windows 中的控制机获取
- vba - 用于缩进“特殊悬挂”的VBA方法...项目符号点和文本之间的间距
- java - SendGrid:找不到符号,com.sendgrid.Email 类。周末断了
- javascript - 如何从一组列表中向下滑动一个列表并单击关闭其他列表?
- python - 在python中构造重复的导入语句
- php - 使用 PHP 和 Jquery 更新动态 HTML 表
- c# - Sql 查询未从数据库中提取所需数据