Skip to content

Release Note 1.9

Soutaro Matsumoto edited this page Feb 18, 2025 · 7 revisions

Some of the highlights in Steep 1.9 are:

  • Steepfile DSL update
  • IDE type checking experience improvement
  • steep check command overhaul
  • steep validate deprecation
  • implicitly-returns-nil support

You can install it with $ gem install steep or using Bundler.

gem 'steep', require: false, '~> 1.9.0'

See the CHANGELOG for the details.

Steepfile DSL update

PRs: #1308

New group construct is introduced under targets for better organization of the Ruby code in your project.

target :app do
  group :models do
    check "app/models"
    signature "sig/app/models"
  end

  group :controllers do
    check "app/controllers"
    signature "sig/app/controllers"
  end

  check "app"
  signature "sig/app"
end

target :test do
  unreferenced!

  check "test"
  signature "sig/test"
end

A Ruby code or RBS file belongs to a target or group. This is changed from Steep 1.8, where a Ruby code belongs to a target but a RBS file can belong to several targets.

If multiple targets/groups covers the file, the first one owns the file. So the app/model/person.rb will belong to app.models group, and app/concerns/person_helper.rb will belong to app target.

Targets and groups are different that targets can have their own library configurations.

Another DSL to mention is unreferenced! method. This tells the classes in the target cannot be referenced from other targets. This helps analyzing the dependencies between classes/modules/targets. You may want to use the method in targets for tests.

Targets and groups are used to define LSP experience and in commandline options.

IDE type checking experience

PRs: #1308, #1340

For better performance, Steep language server now type checks open targets/groups on type definition changes. This improves the responsiveness from the change of a type definition to type checking completion.

This also means files that belongs to closed targets/groups are skipped, and type errors in them are ignored. To mitigate this issue, two commands are added in VSCode extension.

スクリーンショット 2024-12-06 16 20 16

The new Type check project and Type check groups commands allows triggering type checking manually. When you want to type check all of your project, run Type check project. You can also type check some of the targets/groups with Type check groups command.

If your project is big enough, define a few targets and as many groups as you can organize your code base so that each group contain strongly coupled pieces of code. On-the-fly type checking works inside groups, and you will run whole project type checking less frequently.

steep check command overhaul

PRs: #1308, #1387

This is also for performance improvement. steep check command now accepts --group option to type check a group (or a target).

$ steep check --group=app.models      # Type check files in app.models group
$ steep check --group=app.*           # Type check files in all groups in app and the target itself
$ steep check --group=app             # Type check files in target itself, but not in groups in the target

This will help running steep check parallel in CI environment, for quicker CI response.

steep validate deprecation

PRs: #1308, #1346

steep validate command is deprecated and you can use steep check with --validate command.

$ steep check --no-type-check --validate=library        # Skip type checking, validate all RBS files from libraries too

--validate=library is equivalent to the old steep validate command. This validates RBS files from libraries too. I don't recommend strongly this option, because errors are rarely detected from library signatures. The default is --validate=group and I think the option is sufficient for most projects.

implicitly-returns-nil support

PRs: #1258, #1396

implicitly-returns-nil annotation in RBS is supported. This is an opt-in feature target by target basis.

target :lib do
  implicitly_returns_nil!
end

This causes a lot of additional type errors around Array and Hash.

a = [1,2,3]
a[0] + 1          # a[0] may be `nil`, and type error is reported

Important

The #implicitly_returns_nil! is added to Steepfile in Steep 1.9.1. Steep 1.9.0 enables the feature in all targets, which caused a lot of unexpected type errors.

New diagnostics

Four new diagnostics are introduced: