我为ruby代码实现了一个.rbs文件,除了DateTime
之外,其他都可以使用。
拼音文件:
class foo
# other attributes
attr_reader :bar
def initialize(bar)
@bar = bar
end
end
这是rbs文件:
class Foo
# other attributes
attr_reader bar: DateTime
def initialize: (DateTime bar) -> void
end
但是当我运行steep check
时,我得到了以下错误:
path/foo.rbs:14:26: [error] Cannot find type `DateTime`
│ Diagnostic ID: RBS::UnknownTypeName
│
└ attr_reader bar: DateTime
为什么找不到DateTime?是否应使用其他声明?
其余的类型工作正常,无论它们是由我创建的还是基本类型,如Integer
或String
。
谢谢。
1条答案
按热度按时间uajslkp61#
您需要显式地将日期标准库类型添加到
Steepfile
我没有找到任何好的文档,我通过阅读steep's
Steepfile
把它拼凑在一起,这是我猜它是如何工作的:DateTime
,除非你在Steepfile
中明确声明为library
,否则rbs/steep无法使用它们。