dart-archive/angular_analyzer_plugin

The referenced HTML file doesn't exist

Closed this issue · 1 comments

cedx commented

IntelliJ IDEA 2018.1, Dart SDK 2.0.0-dev.43 and Angular 5.0.0-alpha+8.

Probably a bad practice, but I have several components grouped in one Dart library but split in subfolders. The library (app.dart) is located in the lib folder, and the components (app_component.dart, navbar.dart) are in a lib/app folder. The HTML templates are located next to the components (e.g. app_component.html is in the same folder as app_component.dart).

lib/app.dart:

library app;

import 'dart:async';
import 'package:angular/angular.dart';
// [...]

part 'app/app_component.dart';
part 'app/navbar.dart';

lib/app/app_component.dart:

part of app;

@Component(
  directives: const [routerDirectives, Navbar],
  selector: 'application',
  templateUrl: 'app/app_component.html' // <= warning!!!
)
class AppComponent implements OnInit {
  // [...]
}

I have a warning next to the templateUrl field:
The referenced HTML file doesn't exist

This is because templateUrl is resolved relative to the library file (i.e. app.dart) but the Angular analyzer resolves it relative to the component file (i.e. app_component.dart).

Can I silence this warning ? The application is working fine and a non existent template is already reported by the compiler (i.e. Unable to read file).

Thanks @cedx for filing!

Unfortunately we don't have any ways to silence the warnings inside dart files, only html files.

Let me see what I can do! Great edge case!