简体   繁体   中英

Adding Sorbet RBI files to gems

I'm investigating what it might take to add Sorbet RBI files to gems that I maintain, and I'm trying to figure out the proper process for this. I don't want to have Sorbet as a runtime dependency for the gems, though, so that means having all the type information in a separate RBI file.

My current queries around this are:

  • Do I add my own rbi file at, say, ./sorbet/rbi/gemname.rbi ? And is that where Sorbet will look by default if I package that into the published gem file?
  • Should I include the other auto-generated RBI files (in ./sorbet/rbi/sorbet-typed and ./sorbet/rbi/hidden-definitions ) in the published gem file?
  • Should I include the typed pragma comment in my gem's files, even though the type information is separated into an RBI file? If so, should it reflect the type information that's present in the file the comment is in, or should it reflect the type information available via the RBI file?

My understanding (I'm in a similar boat) based reading through the custom RBI content is that they recommend writing the definitions in a rbi directory in the gem root directory. I don't think they should go in the the sorbet directory since that file gets quite large (and you don't want to have gem users having to download MBs of repeated definitions).

I've been putting the typed sigils in the library files that I have definitions for and having the RBI files separate. The srb tc picks up the definitions (and complains as appropriate). This means that I don't need to add sorbet as a gem dependency (other than for development).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM