Tapioca::Dsl::Compilers::ActiveJob creates an invalid RBI for generic job classes
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
Description
Given classes like this
class Operation
abstract!
sig { abstract.void }
def save!; end
end
class OperationJob < Active::Job
extend T::Sig
extend T::Generic
abstract!
OperationType = type_member { { upper: Operations::Model } }
sig { returns(OperationType) }
attr_reader :operation
sig { abstract.returns(T::Class[OperationType]) }
def operation_type; end
def perform(**args)
@operation = operation_type.new(**args)
@operation.save!
end
end
The compiler produces output like this
class. OperationJob
class << self
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.params(job: OperationJob).void)
).returns(T.any(OperationJob, FalseClass))
end
def perform_later(**args, &block); end
sig { params(args: T.untyped).returns(T.untyped) }
def perform_now(**args); end
end
end
This fails type checking with the error Malformed type declaration. Generic class without type arguments.
Locally we worked around this by monkey patching the compiler to skip generics by calling
def decorate
return if constant.is_a?(T::Generic)
# continue with existing code
end
Should this change be upstreamed? If so I'm happy to submit a PR
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Tapioca::Dsl::Compilers::ActiveJob and reproduce the invalid RBI using the generic OperationJob example from the issue. Compare the generated declaration with Sorbet's generic-class requirements and check the existing compiler behavior around decoration. Done means the compiler no longer emits an RBI that fails with “Generic class without type arguments,” with coverage for the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100