Enable module names to be type aliased

Is the ability to type alias module names explicitly not supported or is it just something that hasn't been explored yet?

1 Like

What would you use it for? Languages which support something like this typically have nested modules, but Swift doesn't have submodules, and the default import statement already brings in scope all visible items from the imported module.

I imagine that primary use case for this would be that you want to explicitly qualify the module name when referring to some declaration, to clarify where it is coming from, but the module's name is very long. But Swift modules generally have short names.

Naming conflicts when two imported frameworks share a class with the same name.

For a class, you can create local typealiases once and refer to them.

typealias FMyClass = ModuleF.MyClass
typealias GMyClass = ModuleG.MyClass

Arguably, this is less aesthetic than F.MyClass and G.MyClass but it gets the job done.

I know. What I want to know is what I asked in the first post.

Terms of Service

Privacy Policy

Cookie Policy