对于ruby中的严格类型,我一直很有兴趣采用sorbet,但是在我现有的代码库上安装它时,我碰到了一个我不明白的墙
运行sbc tc时会出现以下错误
entities/user_entities.rb:25: The super class CrewManagement::Entities::UserBase of CrewManagement::Entities::UserEmbeds does not derive from Class https://srb.help/5067
25 | class UserEmbeds < UserBase
^^^^^^^^^^^^^^^^^^^^^^^^^^^
entities/user_entities.rb:6: CrewManagement::Entities::UserBase defined here
6 | class UserBase < CrewManagement::Entities::Mongoid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^误差5067下的冰糕文档
A class’s superclass (the Parent in class Child < Parent) must be statically resolvable to a class, not a module.据我所知,错误是说我的class不是从class继承的,而是从module继承的,但是当我查看所有东西时,我非常肯定所有的东西都是class,而那个冰糕可能会造成错误的结果。
实体/用户实体.
module CrewManagement
module Entities
## inherits from a different file
class UserBase < CrewManagement::Entities::Mongoid
expose :username
## ...
end
## inherits from declaration above
class UserEmbeds < UserBase
expose :_embedded do |record, opt|
embeds = {}
## ...
embeds
end
end
end
endconfig/entities.rb
module CrewManagement
module Entities
## inherits from grape-entity gem
class Mongoid < Grape::Entity
format_with(:mongo_id, &:to_s)
with_options(format_with: :mongo_id) do
expose :_id, as: :id
end
expose :created_at
expose :updated_at
end
end
end我认为它标志着葡萄实体rubygem,而不是我的代码库,但是当我查看rubygems源代码时,我发现Grape::Entity是一个类实体/实体b。
这个错误是我可以通过RBI文件声明来解决的吗?
运行时详细信息:
发布于 2022-09-06 18:57:59
我敢打赌您的todo.rbi文件中有一个声明可以读取module Grape::Entity; end
如果tapioca仍然无法“发现”葡萄的正确类型,则需要手动修改todo.rbi。
编辑:我看你已经有木薯了。如果RBI没有正确解决,您可能需要手动添加它。
https://stackoverflow.com/questions/73626061
复制相似问题