ruby / ruby/rbs

Add a way to mark a method as deprecated in inline RBS

Open
#2,702 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.2k
Forks
256
Avg merge
6d 17h
Merged PRs (30d)
37

Description

For editor support in the Ruby LSP, it'd be great if this were standardized by rbs. See also https://github.com/Shopify/ruby-lsp/issues/1773

I see that there are deprecation signatures in RBS syntax that are generally standardized: https://github.com/ruby/rbs/blob/031f319726752e74499fc7036c9593a3b5d87ed0/sig/definition.rbs#L100

But is there a way to do this in an inline RBS signature? Should there be? Should we consider a @deprecated tag at the start of a comment line to be the standard way to do this, to match YARD/JSDoc and all the gems that already use this syntax?

class Foo
  # @deprecated Use #new_thing instead.
  #: -> String
  def old_thing
    return 'bad'
  end

  #: -> String
  def new_thing
    return 'better'
  end
end

I see that there is one example of an inline comment for a deprecated method, in the tests, but I don't think it technically means anything here.

https://github.com/ruby/rbs/blob/031f319726752e74499fc7036c9593a3b5d87ed0/test/rbs/inline_parser_test.rb#L1305-L1306

I am very much looking forward to Inline RBS! :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading sig/definition.rbs around the deprecated signature and the inline deprecation example in test/rbs/inline_parser_test.rb. Compare what the existing inline parser treats as meaningful with the standardized RBS syntax. Done means the project has a decided, tested way to represent deprecation in inline RBS, if the proposal is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.