Skip to content

Improve template errors detection during compile time. #21

@slavap

Description

@slavap

Not sure it's even possible, but would be nice to have. First the code:

public enum JqmButtonSize {
    SMALL("sm"), LARGE("lg");

    private final String bsSize;

    private JqmButtonSize(String bsSize) {
        this.bsSize = bsSize;
    }

    @JsMethod public String getBsSize() {
        return bsSize;
    }
}

@Component
public class JqmButton extends VueComponent {
    @Prop @JsProperty JqmButtonSize size;

    @Computed public String getCalcSize() {
        return size != null ? size.getBsSize() : "";
    }
}

And then it's used like:

<vue-gwt:import class="com.vx.JqmButtonSize" />
<jqm-button variant="primary" :size="JqmButtonSize.LARGE">Abc</jqm-button>

Probably there is a way to eliminate a need for manual vue-gwt:import, but anyway it works.
Then let's pretend we did some mistakes in template.
In case :size="aaa" we are getting error "Couldn't find variable/method "aaa" in the Component." during compile time, which is good.
But in case :size="222" we are not getting any error during compile time, but getting it in runtime, like "[Vue warn]: Error in render: "TypeError: this.size.getBsSize is not a function", which is too late and not very informative. IMO it would be nice to improve template generator to catch as much as possible Java types errors during compile time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions