Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type.based not working on type if typealias is used #1015

Closed
TitouanVanBelle opened this issue Dec 3, 2021 · 2 comments · Fixed by #1288
Closed

Type.based not working on type if typealias is used #1015

TitouanVanBelle opened this issue Dec 3, 2021 · 2 comments · Fixed by #1288
Assignees
Labels
Milestone

Comments

@TitouanVanBelle
Copy link

TitouanVanBelle commented Dec 3, 2021

Context

I have tried this using the soucery command line or the Sourcery Pro app (version 1.3.4) and I am getting the same result. Below is my current configuration

Sourcery Version

❯ sourcery --version
1.6.0

Sample Code

class ID: ExpressibleByStringLiteral {
    let value: String
    required init(stringLiteral value: StringLiteralType) {
        self.value = value
    }
}

enum Module {
    typealias Model = ModuleModel
}

// sourcery: AutoStub
struct ModuleModel {
    class ModelID: ID {}

    // sourcery: AutoStub
    struct Element {
        let id: ModuleModel.ModelID
        let idUsingTypealias: Module.Model.ModelID
    }
}

Stencil

{% for type in types.types|!enum where type.implements.AutoStub or type|annotated:"AutoStub" %}
    {% for variable in type.storedVariables %}
        {{ variable.name }} // {{ variable.type.based.ExpressibleByStringLiteral }}
    {% endfor %}
{% endfor %}

Actual Generated Code

id // ExpressibleByStringLiteral
idUsingTypealias //

Expected Generated Code

id // ExpressibleByStringLiteral
idUsingTypealias // ExpressibleByStringLiteral
@krzysztofzablocki
Copy link
Owner

Typealiases / module cross resolution is not trivial, this code lives in Composer if you wanted to take a stab at figuring out what's missing.

I'd start with adding a unit test for the example above and seeing where we cut off the resolution incorrectly

@art-divin
Copy link
Collaborator

👋🏻 Hey

Typealiases / module cross resolution is not trivial

I found it trivial to implement, but non trivial to understand how to implement in Composer 👀

Here's the PR fixing the behaviour for good: #1288 👍🏻

@art-divin art-divin self-assigned this Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants