dart-archive/angular_analyzer_plugin

Error for no exported directives in #x="y"

Closed this issue · 1 comments

Example of working code:

@Component(selector: 'blah', template: '<div exportedDirective #newvar="exportedDirective">{{newvar.exportedDirectiveProperty}}</div>')
class BlahComponent {}

@Directive(selector: '[exportedDirective]', exportAs: 'exportedDirective')
class ExportedDirective {
  String exportedDirectiveProperty;
}

This example works and typechecks the property on newvar. However, misspell the "exportAs" identifier, or misspell the selector property:

@Component(selector: 'blah', template: '<div exportedDirective #newvar="exprtedDirctiv">{{newvar.exportedDirectiveProperty}}</div>')
class BlahComponent {}

@Directive(selector: '[exportedDirective]', exportAs: 'exportedDirective')
class ExportedDirective {
  String exportedDirectiveProperty;
}

(causing #newvar="exprtedDirctiv" to have no matching directives to assign to 'newvar)

or

@Component(selector: 'blah', template: '<div exprtdDirctive #newvar="exportedDirective">{{newvar.exportedDirectiveProperty}}</div>')
class BlahComponent {}

@Directive(selector: '[exportedDirective]', exportAs: 'exportedDirective')
class ExportedDirective {
  String exportedDirectiveProperty;
}

(causing ExportedDirective to not match the div, and therefore "#newvar=..." could never possibly find it)

In both cases you get the error "the getter newvar isn't defined for the class BlahComponent" and the squiggles go under the "newvar" in the mustache.

We should instead see squiggles under the attribute value in #newvar="..." and say something to the effect of "No matching directives on this element export themselves under the name exprtdDirctive"