DEV Community

hiko1129
hiko1129

Posted on • Originally published at note.hiko1129.com on

[Ruby][Sorbet] Where should I put the RBI I wrote?

Translate ja to en

結論

sorbet/rbi/shims 以下に置く。

gemの場合には: sorbet/rbi/shims/gems

(Railsの)appの場合には: sorbet/rbi/shims/app
と言った感じで。

根拠

https://sorbet.org/docs/rbi#hand-written-rbis-for-gems には下記が書かれており、

When rbi-central does not have RBI files for a gem, tapioca init will still have created some autogenerated RBI files for that gem. These autogenerated files are a great way to start off writing hand-written RBIs for a gem! Simply copy the autogenerated file from the sorbet/rbi/gems/ folder to sorbet/rbi/shims/gems, and start modifying it by hand.

https://github.com/Shopify/tapioca#manually-writing-rbi-definitions-shims には下記が書かれている。

A shim is a hand-crafted RBI file that tells Sorbet about constants, ancestors, methods, etc. that it can't understand statically and aren't already generated by Tapioca.

Top comments (0)