有没有一种方法可以在不向每个文件中添加#类型注释的情况下使用Sorbet? [英] Is there a way to use Sorbet without adding the # type annotation to every file?

查看:78
本文介绍了有没有一种方法可以在不向每个文件中添加#类型注释的情况下使用Sorbet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始在我的Ruby on Rails项目中使用Sorbet,但是有人要求我不要在每个文件中添加类型注释.

I want to start using Sorbet for my Ruby on Rails project, but I've been asked not to add the type annotation to every file.

是否有一种无需添加注释即可使用Sorbet的方法?

Is there a way to use Sorbet without adding the annotation?

推荐答案

Sorbet支持--typed-override功能,您可以为sorbet提供一个YAML文件,以指定应将哪些文件置于哪个级别: https://github.com/sorbet/sorbet/tree/master/test/cli/override-typed . srb跑步者目前尚不知道,但是社区中一直在谈论增加对它的支持: https://sorbet-ruby.slack.com/archives/CHN2L03NH/p1563404308018500

Sorbet supports --typed-override feature where you can give sorbet a YAML file to specify what files should go into what level: https://github.com/sorbet/sorbet/tree/master/test/cli/override-typed. srb runner doesn't currently know about it, but there has been chatter in the community about adding support for it: https://sorbet-ruby.slack.com/archives/CHN2L03NH/p1563404308018500

请注意,根据我们在Stripe的经验,我们发现在键入的文件中包含typed: true信号具有很大的价值,因为它允许用户构建&验证他们对键入什么和不键入什么的期望.

Note that from our experience at Stripe we found that having typed: true sigils in typed files has a lot of value as it allows users to build & verify their expectations on what is typed and what is not.

这篇关于有没有一种方法可以在不向每个文件中添加#类型注释的情况下使用Sorbet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆