Tapioca::Dsl::Compilers::ActiveJob creates an invalid RBI for generic job classes
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
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.
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
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
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.
More from Shopify/tapioca
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bensheldon/good_job#1816 · 5 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·