Sha256: 9100defa46451bbbd5a7f6343c547db7f1979ba07a67bdb33db6f081b685613f
Contents?: true
Size: 893 Bytes
Versions: 4
Compression:
Stored size: 893 Bytes
Contents
# typed: strict # frozen_string_literal: true module Tapioca module Gem module Listeners class SorbetProps < Base extend T::Sig private sig { override.params(event: ScopeNodeAdded).void } def on_scope(event) constant = event.constant node = event.node return unless T::Props::ClassMethods === constant constant.props.map do |name, prop| type = prop.fetch(:type_object, "T.untyped").to_s.gsub(".returns(<VOID>)", ".void") default = prop.key?(:default) || prop.key?(:factory) ? "T.unsafe(nil)" : nil node << if prop.fetch(:immutable, false) RBI::TStructConst.new(name.to_s, type, default: default) else RBI::TStructProp.new(name.to_s, type, default: default) end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems