Skip to content

Handle Rubyland dependency resolution#14

Draft
demsullivan wants to merge 2 commits intomainfrom
automatic-aliases
Draft

Handle Rubyland dependency resolution#14
demsullivan wants to merge 2 commits intomainfrom
automatic-aliases

Conversation

@demsullivan
Copy link
Copy Markdown
Owner

@demsullivan demsullivan commented Oct 26, 2023

The goal of this PR is to establish core support for dry-types/dry-struct dependency resolution in Rubyland.

What this means is that dry-typescript needs to do its best to identify and follow references from a type to another type, possibly in another module.

A simple example:

module Types
  include Dry.Types()
  extend Dry::Typescript

  UUID = Types::String
  # In this line, the UUID constant is being referenced. dry-typescript needs
  # to know about this and track it. Since types aren't classes or modules, they don't have a
  # `.name` method to work with.
  ts_export User = Types::Hash.schema(id: UUID)

  finalize_ts_exports!

A more complex example:

module Types
  include Dry.Types()

  UUID = Types::String
  User = Types::Hash.schema(id: UUID)
end

module TypeExports
  extend Dry::Typescript

  # Types::User is being referenced here. dry-typescript needs to know about
  # and track this dependency on Types::User, but also the subsequent dependency
  # on Types::UUID, in order to export the correct type aliases.
  ts_export Users = Types::Array.of(Types::User)

Fixes #10
Fixes #13

@demsullivan demsullivan changed the title Automatically name constants, follow unexported constants, and support cross-module references Handle Rubyland dependency resolution Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatically add aliases on exported types Automatically detect and either warn or follow un-exported dependencies

1 participant