Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Types teaches success, what will we do?

Fu-ga
September 11, 2022

Types teaches success, what will we do?

at RubyKaigi 2022

Fu-ga

September 11, 2022
Tweet

More Decks by Fu-ga

Other Decks in Technology

Transcript

  1. RubyKaigi 2022 @Mie Center for the Arts Types Teaches success,

    what will we do? 2022.09.08(Thu) Fu-ga / ESM, Inc.
  2. Fu-ga @fugakkbn   Ruby on Rails engineer   Work at

    ESM, Inc.   gem_rbs_collection contributor   Interested in “Types” related technologies for Ruby
  3. ×

  4. RubyKaigi 2022 @Mie Center for the Arts Types Teaches success,

    what will we do? 2022.09.08(Thu) Fu-ga / ESM, Inc.
  5. We can now write static types in Ruby RBS, Steep

    Starting with Ruby 3.0, those are bundled with Ruby 💎 Can start small No impact on runtime No loss of writing comfort Product code and type definitions are separated
  6. Most gem type definitions are missing ✓Many projects rely on

    third-party gems ✓About 173,000 gems registered at rubygems.org ✓In contrast, gem_rbs_collection still has only about 40 gem type definitions😢
  7. Centralized repository for gem type definitions ”DefinitelyTyped" in TypeScript More

    type definitions here are expected to make it easier to implement into projects.
  8. Notice   I ’m a contributor and not the maintainer

    of   gem_rbs_collection   I'll speak based on my experience so far, but it   may differ from the maintainer's intentions RBS syntax is not discussed.
  9. Steps to contribute Finding Finding missing or incorrect type definitions

    Check Check for mismatch between type definition and implementation Fix Fix the appropriate rbs file Patch Open a Pull Request
  10. Steps to contribute Finding Finding missing or incorrect type definitions

    Check Check for discrepancies between errors and implementation Fix Fix the appropriate rbs file Patch Open a Pull Request
  11. Two more cases ✓Automatic and exhaustive generation ✓Add only some

    of them These steps are almost identical, differing only in the way the RBS is defined
  12. " Writing high-quality type definitions are difficult. Focus on examples

    available through the README or docs of the gem. Focus on the APIs your app is using. https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md
  13. " Writing high-quality type definitions are difficult. Focus on examples

    available through the README or docs of the gem. Focus on the APIs your app is using. https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md
  14. Partitive Exhaustive How should we use How should we use

    them differently? them differently?
  15. ✓If you want a tight type definition for a particular

    method ✓If you want RBS for now 👉Partitive 👉Exhaustive
  16. FYI REMOVE manifest.yml The file manifest.yml is necessary if there

    are dependencies that are not described in Gemfile.lock or gemspec. If there are no dependencies, remove it before opening PR NOT ALL GEMS ARE COVERED Standard and built-in library RBS files are available in the ruby/rbs repository
  17. WHAT WANTED TO TELL Let's actively use RBS, Steep and

    share our knowledges I hope that the Ruby type ecosystem will develop further