Sha256: d9a3266826892cb0a4c49ba1dd27a7aa72a72d3e75b7d3fcd161c43a7f276f0f
Contents?: true
Size: 1.04 KB
Versions: 30
Compression:
Stored size: 1.04 KB
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 sig { override.params(event: NodeAdded).returns(T::Boolean) } def ignore?(event) event.is_a?(Tapioca::Gem::ForeignScopeNodeAdded) end end end end end
Version data entries
30 entries across 30 versions & 2 rubygems