Class: Tapioca::Dsl::Compilers::SorbetTypedPropsConstructor::PropToParamConverter::Details

Inherits:
T::ImmutableStruct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tapioca/dsl/compilers/sorbet_typed_props_constructor/prop_to_param_converter.rb

Overview

representation of sorbet prop details

Defined Under Namespace

Classes: ParamValueEnum

Instance Method Summary collapse

Instance Method Details

#optional?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tapioca/dsl/compilers/sorbet_typed_props_constructor/prop_to_param_converter.rb', line 29

def optional?
  # NOTE: explicitly not checking for _tnilable. This makes nilable
  # props required, when no default or factory is set. The default
  # behavior would have been to be optional with an implied default
  # of nil
  # (https://sorbet.org/docs/tstruct#tnilable-without-implying-default-nil).
  # But because we don't know here, if a type alias has been used as
  # workaround not not imply default, we simply never treat nilable
  # as optional.
  default != ParamValueEnum::ParamNotPresent || factory != ParamValueEnum::ParamNotPresent
end