-
Notifications
You must be signed in to change notification settings - Fork 217
Release Note 3.9
Some of the highlights in RBS 3.9 are:
- Add
resolve-type-names: false
magic comment (#2234) - Annotations on constants, globals, class/module aliases (#2302)
- Annotation processing overhaul (#2301)
- Improved validation (#2237, #2241, #2289, #2294, #2300)
- Untyped proc type can have
self
type hint (#2325) - Replace
%a{steep:deprecated}
with%a{deprecated}
(#2328)
You can install it with $ gem install rbs
or using Bundler.
gem 'rbs', '~> 3.9.0'
Read the CHANGELOG for the details.
PR: #2234
You can add resolve-type-names: false
magic comment at the beginning of RBS files to skip type name resolution. This makes RBS file loading faster, typically for generated RBS files where the type names can be identified already.
# resolve-type-names: false
class Foo
def foo: () -> ::String # ::String should be used instead of String
end
PR: #2302
Constant declarations, global declarations, and class/module alias declarations can be annotated.
%a{deprecated}
VERSION: String
%a{deprecated}
$NAME: String
%a{deprecated}
module Foo = Kernel
PR: #2301
Annotations given to method definition resets to its aliases.
class Test
%a{deprecated}
def foo: %a{implicitly-returns-nil} () -> String
alias bar foo
end
In this example, %a{deprecated}
annotation is given to the def
syntax of foo
, while the %a{implicitly-returns-nil}
annotation is attached to the method overload. Because the annotation on def
syntax resets on alias
, bar
doesn't have %a{deprecated}
annotation. However, %a{implicitly-returns-nil}
is attached the overload, and the method overload in bar
inherits the annotations.
Annotations on class/module aliases also resets the original annotations.
%a{deprecated}
class Test
end
class Test2 = Test
::Test
is deprecated but ::Test2
is not.
Note that RBS::Definition::Method::TypeDef#annotations
is deprecated with this. It now has #member_annotations
for annotations on the method definition and #overload_annotations
for annotations on the overload.
PRs: #2237, #2241, #2289, #2294, #2300
RBS 3.9 introduces some validations.
class Foo < Array # Rejects incorrect type application
@foo: String
@foo: Integer # Rejects the duplicated instance variable declaration
@bar: String[Integer] # Rejects variable type validation
end
Note that instance variable declaration duplication validation works for variable declarations but skips instance variables defined through attr_reader
-likes.
PR: #2325
Untyped proc types, ^(?) -> T
, can have self
type hint.
type t = ^(?) [self: String] -> void
PR: #2328
RBS now ships with %a{deprecated}
annotation. The annotation is supported with Steep >= 1.10.
%a{deprecated}
VERSION: String
%a{deprecated: Use `RBS::VERSION` instead}
VERSION: String
The %a{deprecated}
annotation can have optional message after :
which is printed on diagnostics to help migration.