Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental: Publish RBI signatures to enable type-checked TDD #22

Merged
merged 205 commits into from
Aug 24, 2023

Conversation

searls
Copy link
Member

@searls searls commented Jun 3, 2023

This isn't close to ready yet, but I've made some progress. Will write more here when there's more to say.

searls added 30 commits May 21, 2023 10:08
yields:

The sorbet/ folder should exist and look something like this:

├── config             # Default options to be passed to Sorbet on every run
└── rbi/
  ├── annotations/     # Type definitions pulled from the rbi-central repository
  ├── gems/            # Autogenerated type definitions for your gems
  └── todo.rbi         # Constants which were still missing after RBI generation
└── tapioca/
  ├── config.yml       # Default options to be passed to Tapioca
  └── require.rb       # A file where you can make requires from gems that might be needed for gem RBI generation

Please check this folder into version control.

🤔 What's next

1. Many Ruby applications use metaprogramming DSLs to dynamically generate constants and methods.
  To generate type definitions for any DSLs in your application, run:

  bin/tapioca dsl

2. Check whether the constants in the sorbet/rbi/todo.rbi file actually exist in your project.
  It is possible that some of these constants are typos, and leaving them in todo.rbi will
  hide errors in your application. Ideally, you should be able to remove all definitions
  from this file and delete it.

3. Typecheck your project:

  bundle exec srb tc

  There should not be any typechecking errors.

4. Upgrade a file marked "# typed: false" to "# typed: true".
  Then, run: bundle exec srb tc and try to fix any errors.

  You can use Spoom to bump files for you:

  spoom bump --from false --to true

  To learn more about Spoom, visit: https://github.com/Shopify/spoom

5. Add signatures to your methods with sig. To learn how, read: https://sorbet.org/docs/sigs

Documentation
We recommend skimming these docs to get a feel for how to use Sorbet:
- Gradual Type Checking: https://sorbet.org/docs/gradual
- Enabling Static Checks: https://sorbet.org/docs/static
…e via tests that something fails a type check
… if I define the method signature exactly how it generates it by default?

It fails silently when it doesn't incorporate a signature, which is unhelpful (I thought this was working previously)
This reverts commit bd8aad6.
@searls searls merged commit 43dc4f7 into main Aug 24, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant