Jake Zimmerman
Jake Zimmerman
We have a policy of testing changes to Sorbet against Stripe's codebase before merging them. I've kicked off a test run for the current PR. When the build finishes, I'll...
While the feature request is admirable, I worry that there's no convenient way to implement this in Sorbet. I'm happy for someone to prove me wrong, but I would not...
It's worth noting that TypeScript doesn't appear to implement this feature either.
Here's another one: if `T::Module` existed, we could improve our support for `
#### Input [→ View on sorbet.run](https://sorbet.run/#%23%20typed%3A%20__STDLIB_INTERNAL%0Aextend%20T%3A%3ASig%0A%0Amodule%20Mixin%0Aend%0A%0Aclass%20Example%0A%20%20include%20Mixin%0Aend%0A%0Aclass%20Parent%3B%20end%0Aclass%20Child%20%3C%20Parent%3B%20end%0A%0Asig%20%7B%0A%20%20type_parameters%28%3AU%29%0A%20%20.params%28klass%3A%20T%3A%3AClass%5BT.type_parameter%28%3AU%29%5D%2C%20obj%3A%20T.anything%29%0A%20%20.returns%28T.type_parameter%28%3AU%29%29%0A%7D%0Asig%20%7B%0A%20%20type_parameters%28%3AInput%29%0A%20%20.params%28klass%3A%20Module%2C%20obj%3A%20T.type_parameter%28%3AInput%29%29%0A%20%20.returns%28T.type_parameter%28%3AInput%29%29%0A%7D%0Adef%20my_is_a%3F%28klass%2C%20obj%29%0A%20%20case%20obj%0A%20%20when%20klass%0A%20%20%20%20obj%0A%20%20else%0A%20%20%20%20raise%0A%20%20end%0Aend%0A%0Ares%20%3D%20my_is_a%3F%28Example%2C%20Example.new%29%0AT.reveal_type%28res%29%0Ares%20%3D%20my_is_a%3F%28Mixin%2C%20Example.new%29%0AT.reveal_type%28res%29%0A%0Ares%20%3D%20my_is_a%3F%28Child%2C%20Parent.new%29%0AT.reveal_type%28res%29%0Ares%20%3D%20my_is_a%3F%28Mixin%2C%20Parent.new%29%0AT.reveal_type%28res%29) ```ruby # typed: __STDLIB_INTERNAL extend T::Sig module Mixin end class Example include Mixin end class Parent; end class Child < Parent; end sig {...
#### Input [→ View on sorbet.run](https://sorbet.run/#%23%20typed%3A%20strict%0Aextend%20T%3A%3ASig%0A%0AMapping%20%3D%20T.let%28%7B%7D%2C%20T%3A%3AHash%5BT%3A%3AClass%5BT.anything%5D%2C%20T.anything%5D%29%0A%0Asig%20%7B%0A%20%20type_parameters%28%3AInst%29%0A%20%20%20%20.params%28klass%3A%20T%3A%3AClass%5BT.type_parameter%28%3AInst%29%5D%29%0A%20%20%20%20.returns%28T.type_parameter%28%3AInst%29%29%0A%7D%0Adef%20get_instance%28klass%29%0A%20%20impl%20%3D%20Mapping%5Bklass%5D%0A%20%20res%20%3D%20case%20impl%0A%20%20when%20klass%20then%20impl%0A%20%20else%20raise%0A%20%20end%0A%20%20res%0Aend) ```ruby # typed: strict extend T::Sig Mapping = T.let({}, T::Hash[T::Class[T.anything], T.anything]) sig { type_parameters(:Inst) .params(klass: T::Class[T.type_parameter(:Inst)]) .returns(T.type_parameter(:Inst)) } def get_instance(klass) impl = Mapping[klass] res...
Sorbet could ignore `T.unsafe`, e.g., treat `T.unsafe` as being defined like this: ```ruby module T sig do type_parameters(:U) .params(x: T.type_parameter(:U)) .returns(T.type_parameter(:U)) end def self.unsafe(x); x; end end ``` The problem...
Some tests failed, and also this is going to need runtime support.
The underlying issue here is that Sorbet doesn't have separate types for lambdas and procs. Sorbet tries to get around this by sometimes choosing to back `T.proc` types by behavior...
I've released a Lua filter, as an alternative to the JSON filter. https://github.com/jez/pandoc-sidenote/blob/master/README.md The Lua filter should be equivalent in functionality, but not have the same API compatibility restrictions that...