Skip to content

Improve generator type inferencing #15

@nickhendo

Description

@nickhendo

Certain fields can have more information inferred from them, such as if a field is part of a for loop, we can reasonably infer that it is of type Iterable for example.

Another example would be within a field that is iterated through, we don't currently generate types for the fields that would be attached to that field. E.g.

            {% block post_grid %}
            {% for post in posts %}
            <div hx-get="{{ post.slug }}" class="bg-gradient-to-br from-gray-800/50 to-gray-900/50 rounded-2xl p-6 border border-gray-700/50 card-hover">
                <div class="flex items-center space-x-2 mb-4">
                    <span class="bg-volt-yellow/10 text-volt-yellow text-xs font-semibold px-3 py-1 rounded-full">{{ post.category }}</span>
                </div>
                <h3 class="text-xl font-bold mb-3 hover:text-volt-yellow transition-colors cursor-pointer">
                    {{ post.title }}
                </h3>
                <p class="text-gray-300 mb-4">
                    {{ post.description }}
                </p>
                <div class="flex items-center justify-between text-sm text-gray-400">
                    <span>{{ post.date }}</span>
                    <span>{{ post.read_time }}</span>
                </div>
            </div>
            {% endfor %}
            {% endblock %}

This generates the type posts (which should be inferred as an Iterable), but none of slug, title, description, date or read_time are generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions