在RBS文件上使用Gemfile中的类

发布于 2025-02-09 11:47:43 字数 510 浏览 2 评论 0原文

我正在.rbs Ruby中的文件中工作,我和我的应用程序都在工作,直到我决定声明redis中键入.rbs文件。

我使用的是gemfile redis

,然后我有此功能:

  def redis_connect
    Redis.new(host: REDIS_HOST, port: REDIS_PORT, password: REDIS_PASSWORD)
  end

.rbs文件中,文件看起来像下一个:

def redis_connect: () -> Redis

但是我得到了错误找不到REDIS

是否可以“键入” redis?还是我需要离开它untyped

谢谢

I am working in .rbs files in ruby and I and everything were working inside my app until I decided to declare the Redis type in the .rbs file.

I am using the gemfile redis

and then I have this function:

  def redis_connect
    Redis.new(host: REDIS_HOST, port: REDIS_PORT, password: REDIS_PASSWORD)
  end

which in the .rbs file looks like the next:

def redis_connect: () -> Redis

But I am getting the error cannot find Redis

is it possible to "type" Redis? or do I need to leave it untyped?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文