Class: CustomElementsManifestParser::Nodes::JavaScriptExport

Inherits:
BaseStruct
  • Object
show all
Includes:
Mixins::HasParentModule, Structs::DeclarableNodeStruct
Defined in:
lib/custom_elements_manifest_parser/nodes/javascript_export.rb

Overview

A JavaScript export!

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::HasParentModule

#parent_module

Instance Attribute Details

#declarationReference

Returns - A reference to the exported declaration.

In the case of aggregating exports, the reference's module field must be defined and the name field must be "*".

Returns:

  • (Reference)

    - A reference to the exported declaration.

    In the case of aggregating exports, the reference's module field must be defined and the name field must be "*".



41
# File 'lib/custom_elements_manifest_parser/nodes/javascript_export.rb', line 41

attribute :declaration, Types::Nominal::Any.optional.meta(required: false)

#deprecatednil, ...

Returns - Whether the export is deprecated. For example, the name of the export was changed. If the value is a string, it's the reason for the deprecation.

Returns:

  • (nil, boolean, string)

    - Whether the export is deprecated. For example, the name of the export was changed. If the value is a string, it's the reason for the deprecation.



47
# File 'lib/custom_elements_manifest_parser/nodes/javascript_export.rb', line 47

attribute :deprecated, Types::Strict::String.optional | Types::Strict::Bool.optional.meta(required: false)

#kind"js"

Returns:

  • ("js")


17
# File 'lib/custom_elements_manifest_parser/nodes/javascript_export.rb', line 17

attribute :kind, Types.Value("js")

#nameString

Returns - The name of the exported symbol.

JavaScript has a number of ways to export objects which determine the correct name to use.

  • Default exports must use the name "default".
  • Named exports use the name that is exported. If the export is renamed with the "as" clause, use the exported name.
  • Aggregating exports (* from) should use the name *.

Returns:

  • (String)

    - The name of the exported symbol.

    JavaScript has a number of ways to export objects which determine the correct name to use.

    • Default exports must use the name "default".
    • Named exports use the name that is exported. If the export is renamed with the "as" clause, use the exported name.
    • Aggregating exports (* from) should use the name *


33
# File 'lib/custom_elements_manifest_parser/nodes/javascript_export.rb', line 33

attribute :name, Types::Strict::String

Class Method Details

.kind"js"

Returns:

  • ("js")


20
# File 'lib/custom_elements_manifest_parser/nodes/javascript_export.rb', line 20

def self.kind; "js"; end

Instance Method Details

#visit(parser:) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/custom_elements_manifest_parser/nodes/javascript_export.rb', line 49

def visit(parser:)
  hash = {}
  hash[:declaration] = parser.data_types[:declaration].new(declaration).visit(parser: parser) if declaration

  hash = hash.merge(
    Structs::DeclarableNodeStruct.build_hash(parser: parser, struct: self)
  )

  new(hash)
end