DEV Community

hiko1129
hiko1129

Posted on • Originally published at note.hiko1129.com on

[Ruby][Sorbet] How to make a Rakefile typed

Translate ja to en

https://github.com/ruby/rake/blob/master/lib/rake/dsl_definition.rb#L195 にて

self.extend Rake::DSL
Enter fullscreen mode Exit fullscreen mode

となっているのでそれを表現したT.all(Rake::DSL, Object)をselfとする(厳密には正しくない...)。

# typed: true

T.bind(self, T.all(Rake::DSL, Object)) # ← selfは実行時エラーになるのでせいぜいObjectっぽい

namespace :hoge
  task hoge: :environment do
  end
end
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️