【发布时间】:2020-01-07 03:46:24
【问题描述】:
我已经在 Rails 代码库中安装了 Sorbet,并且看到许多出现以下错误的实例:
sorbet/rbi/sorbet-typed/lib/activerecord/all/activerecord.rbi:958:
Method ActiveRecord::ConnectionAdapters::TableDefinition#column redefined without matching argument count. Expected: 3, got: 5 https://srb.help/4010
958 | def column(
959 | name,
960 | type,
961 | index: nil,
962 | default: nil,
963 | **options
964 | ); end
sorbet/rbi/gems/activerecord.rbi:5256: Previous definition
5256 | def column(name, type, **options); end
要消除类型错误,我要么必须将其中一个文件中的 typed: true 更改为 typed: false(不包括一些不重叠的类型),要么我必须手动进入并删除/注释掉重叠的方法(这既耗时又脆弱)。
我想知道是否有某种程序化解决方案,我可以说“如果发生冲突,请使用具有更高数量的方法”或“始终选择 sorbet 类型的定义。”
这又是在 Rails 代码库中,但我想这将存在于手动生成和自动生成的 RBI 之间的任何冲突。
【问题讨论】:
标签: sorbet