Skip to content

Spike/add type sigs - #44

Open
ajtucker wants to merge 13 commits into
spike/v2from
spike/add-type-sigs
Open

Spike/add type sigs#44
ajtucker wants to merge 13 commits into
spike/v2from
spike/add-type-sigs

Conversation

@ajtucker

@ajtucker ajtucker commented Aug 6, 2026

Copy link
Copy Markdown

Ruby now has support for writing type signature files and running static type checking. The type signatures can be bundled in a Gem for use in type checking downstream apps.

This PR:

  • Adds a dev dependency on steep (the type checker).
  • Brings in type signatures for dependent Gems:
    rbs collection init
    rbs collection install
  • Generates prototype type signatures from source using rbs prototype:
    for rb in lib/data_services_api/*.rb; do rbs prototype rb $rb > sig/data_services_api/$(basename $rb)s; done
  • Sprinkles some type declarations.
  • Adds a GitHub Action to run type checks on pull_requests.

For now, we just report any errors, using bundle exec steep check --severity-level=error.

Note that the Value class has been changed slightly: it assumed that hash keys would be symbols, but by default JSON.parse will use strings for keys unless told otherwise. This may affect downstream use, but we should be able to use the type checker to tell us.

The type signatures for dependent gems are not stored in git, but there is a lockfile to ensure that the same versions are downloaded when running the type checker e.g. in the GitHub action. The lockfile can be updated with rbs collection update

@joescottdave joescottdave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really familiar with any of Ruby's type-checking systems, but this is (I'm told) the way the wind is blowing if you want types in Ruby. This gem seems as good a place as any to try them out.

All looks sound to me so far.

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.

2 participants