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

Angular components can't cope with import aliases with providers and constructor parameters #245

Closed
zoechi opened this issue Jan 3, 2017 · 12 comments

Comments

Projects
None yet
2 participants
@zoechi
Copy link

commented Jan 3, 2017

import 'package:angular2/core.dart' as _i1;
import 'package:fhir_client/webui.dart' as _i2;
import 'package:bwu_ng_mdl/bwu_ng_mdl.dart' as _i3;
import 'package:angular2_components/angular2_components.dart' as _i4;
import 'dart:core' as _i5;

@_i1.Component(
    selector: 'fhir-gen-app',
    templateUrl: 'app_component.html',
    styleUrls: const [
      'app_component.css'
    ],
    providers: const [
      _i2.ToolbarService,
   // ^^^
      _i3.MediaQueryService,
   // ^^^
      _i4.materialProviders
   // ^^^
    ])
class AppComponent {
  final _i2.AlertService alertService;
     // ^^^

  final _i2.ToolbarService toolbarService;
     // ^^^

  _i5.String title = '';

  _i5.bool mobileView = false;

  AppComponent(this.alertService, this.toolbarService) {
    toolbarService.title.listen(_titleUpdateHandler);
  }

  @_i1.HostBinding('class.mobile-view')
  _i5.bool get mobileViewCssClass => mobileView;

  @_i1.HostBinding('class.desktop-view')
  _i5.bool get desktopViewCssClass => mobileView;

  void _titleUpdateHandler(_i5.List value) {
    title = value.join('-');
  }

  _i5.bool get isIndeterminateAction => toolbarService.isIndeterminateAction;
}
Build completed successfully
Build error:
Transform DirectiveProcessor on test_project|lib/generated/components/app_component.dart threw error: Invalid argument(s): Incorrect identifier "_i2.ToolbarService".
package:angular2/src/transform/common/type_metadata_reader.dart 1316:7   _readIdentifier
package:angular2/src/transform/common/type_metadata_reader.dart 1074:14  _readProviders.<fn>
dart:_internal/iterable.dart 416                                         MappedListIterable.elementAt
dart:_internal/iterable.dart 222                                         ListIterable.toList
package:angular2/src/transform/common/type_metadata_reader.dart 1087:6   _readProviders
package:angular2/src/transform/common/type_metadata_reader.dart 626:24   _DirectiveMetadataVisitor._populateProviders
package:angular2/src/transform/common/type_metadata_reader.dart 729:9    _DirectiveMetadataVisitor.visitNamedExpression
package:analyzer/src/dart/ast/ast.dart 7455:15                           NamedExpressionImpl.accept
package:analyzer/src/dart/ast/ast.dart 7743:20                           NodeListImpl.accept
package:analyzer/src/dart/ast/ast.dart 432:16                            ArgumentListImpl.visitChildren
package:analyzer/dart/ast/visitor.dart 1353:10                           Object&RecursiveAstVisitor.visitArgumentList
package:analyzer/src/dart/ast/ast.dart 428:15                            ArgumentListImpl.accept
package:analyzer/src/dart/ast/ast.dart 323:17                            AnnotationImpl.visitChildren
package:analyzer/dart/ast/visitor.dart 1347:10                           Object&RecursiveAstVisitor.visitAnnotation
package:angular2/src/transform/common/type_metadata_reader.dart 441:28   _DirectiveMetadataVisitor.visitAnnotation
package:analyzer/src/dart/ast/ast.dart 317:15                            AnnotationImpl.accept
package:analyzer/src/dart/ast/ast.dart 7743:20                           NodeListImpl.accept
package:angular2/src/transform/common/type_metadata_reader.dart 672:19   _DirectiveMetadataVisitor.visitClassDeclaration
package:analyzer/src/dart/ast/ast.dart 1852:15                           ClassDeclarationImpl.accept
package:angular2/src/transform/common/type_metadata_reader.dart 72:10    TypeMetadataReader.readTypeMetadata
package:angular2/src/transform/directive_processor/rewriter.dart 98:10   _NgMetaVisitor.visitClassDeclaration
package:analyzer/src/dart/ast/ast.dart 1852:15                           ClassDeclarationImpl.accept
package:analyzer/src/dart/ast/ast.dart 7743:20                           NodeListImpl.accept
package:angular2/src/transform/directive_processor/rewriter.dart 92:30   _NgMetaVisitor.visitCompilationUnit
package:analyzer/src/dart/ast/ast.dart 2445:15                           CompilationUnitImpl.accept
package:angular2/src/transform/directive_processor/rewriter.dart 52:16   createNgMeta.<async>.<fn>.<async>
dart:async/future.dart 184                                               Future.Future.microtask.<fn>
dart:async/zone.dart 1150                                                _rootRun
dart:async/zone.dart 1026                                                _CustomZone.run
dart:async/zone.dart 953                                                 _CustomZone.bindCallback.<fn>
dart:async/schedule_microtask.dart 41                                    _microtaskLoop
dart:async/schedule_microtask.dart 50                                    _startMicrotaskLoop
dart:isolate-patch/isolate_patch.dart 96                                 _runPendingImmediateCallback
dart:isolate-patch/isolate_patch.dart 149                                _RawReceivePortImpl._handleMessage

package:angular2/src/transform/common/type_metadata_reader.dart 1316:7   _readIdentifier
package:angular2/src/transform/common/type_metadata_reader.dart 1074:14  _readProviders.<fn>
dart:_internal                                                           ListIterable.toList
package:angular2/src/transform/common/type_metadata_reader.dart 1087:6   _readProviders
package:angular2/src/transform/common/type_metadata_reader.dart 626:24   _DirectiveMetadataVisitor._populateProviders
package:angular2/src/transform/common/type_metadata_reader.dart 729:9    _DirectiveMetadataVisitor.visitNamedExpression
package:analyzer/src/dart/ast/ast.dart 7455:15                           NamedExpressionImpl.accept
package:analyzer/src/dart/ast/ast.dart 7743:20                           NodeListImpl.accept
package:analyzer/src/dart/ast/ast.dart 432:16                            ArgumentListImpl.visitChildren
package:analyzer/dart/ast/visitor.dart 1353:10                           Object&RecursiveAstVisitor.visitArgumentList
package:analyzer/src/dart/ast/ast.dart 428:15                            ArgumentListImpl.accept
package:analyzer/src/dart/ast/ast.dart 323:17                            AnnotationImpl.visitChildren
package:analyzer/dart/ast/visitor.dart 1347:10                           Object&RecursiveAstVisitor.visitAnnotation
package:angular2/src/transform/common/type_metadata_reader.dart 441:28   _DirectiveMetadataVisitor.visitAnnotation
package:analyzer/src/dart/ast/ast.dart 317:15                            AnnotationImpl.accept
package:analyzer/src/dart/ast/ast.dart 7743:20                           NodeListImpl.accept
package:angular2/src/transform/common/type_metadata_reader.dart 672:19   _DirectiveMetadataVisitor.visitClassDeclaration
package:analyzer/src/dart/ast/ast.dart 1852:15                           ClassDeclarationImpl.accept
package:angular2/src/transform/common/type_metadata_reader.dart 72:10    TypeMetadataReader.readTypeMetadata
package:angular2/src/transform/directive_processor/rewriter.dart 98:10   _NgMetaVisitor.visitClassDeclaration
package:analyzer/src/dart/ast/ast.dart 1852:15                           ClassDeclarationImpl.accept
package:analyzer/src/dart/ast/ast.dart 7743:20                           NodeListImpl.accept
package:angular2/src/transform/directive_processor/rewriter.dart 92:30   _NgMetaVisitor.visitCompilationUnit
package:analyzer/src/dart/ast/ast.dart 2445:15                           CompilationUnitImpl.accept
package:angular2/src/transform/directive_processor/rewriter.dart 52:16   createNgMeta.<async>.<fn>.<async>

This works fine though

@_i1.AngularEntrypoint('generic')
void main() {
  _i2.initLogging();
  _i3.bootstrap(_i4.AppComponent, [_i5.rootProviders]);
}

import 'dart:core' as _i1;
import 'package:angular2/core.dart' as _i2;
import 'package:test_project/generated/data_sources/mita_tac.dart' as _i3;
import 'package:angular2/router.dart' as _i4;
import 'package:angular2/platform/common.dart' as _i5;
import 'package:fhir_client/util.dart' as _i6;
import 'package:test_project/entry_points/run_mode.dart' as _i7;
import 'package:fhir_client/util/json_pretty_print_service_browser.dart' as _i8;
import 'package:fhir_client/webui.dart' as _i9;
import 'package:http/http.dart' as _i10;
import 'package:http/browser_client.dart' as _i11;

final _i1.List rootProviders = [
  _i2.provide('DataSourceMitaTac', useValue: _i3.MitaTac),
  _i4.ROUTER_PROVIDERS,
  _i2.provide(_i5.APP_BASE_HREF, useValue: '/'),
  _i2.provide(_i5.LocationStrategy, useClass: _i5.LocationStrategy),
  _i2.provide(_i6.RunMode, useValue: _i7.runMode),
  _i2.provide(_i6.JsonPrettyPrintService,
      useClass: _i8.JsonPrettyPrintServiceBrowser),
  _i2.provide(_i9.AlertService, useClass: _i9.AlertServiceBrowser),
  _i2.provide(_i10.BaseClient, useValue: _i11.BrowserClient)
];
@zoechi

This comment has been minimized.

Copy link
Author

commented Jan 3, 2017

... which makes generating components using code_builder impossible :-/

@matanlurey

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2017

@zoechi

This comment has been minimized.

Copy link
Author

commented Jan 3, 2017

@matanlurey that would work for me. How can I do that? Haven't found anything myself yet.

@matanlurey

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2017

@zoechi

This comment has been minimized.

Copy link
Author

commented Jan 3, 2017

But then I get no imports at all, or am I doing it wrong?
The automatically resolved imports are one of the main reasons why I use code_builder

@matanlurey

This comment has been minimized.

Copy link
Contributor

commented Jan 3, 2017

@zoechi

This comment has been minimized.

Copy link
Author

commented Jan 3, 2017

Thanks for the info! Sure, will have another look. End of day here anyway.

@zoechi

This comment has been minimized.

Copy link
Author

commented Jan 4, 2017

@matanlurey thanks for the hint.
I could make it work using new LibraryBuilder.scope(scope: new Scope.dedupe())

@matanlurey

This comment has been minimized.

Copy link
Contributor

commented Mar 16, 2017

Requires the new compiler.

@matanlurey

This comment has been minimized.

Copy link
Contributor

commented May 12, 2017

This should be ready as part of the 4.0 release.

@matanlurey

This comment has been minimized.

Copy link
Contributor

commented May 24, 2017

Blocked by #404.

@matanlurey

This comment has been minimized.

Copy link
Contributor

commented Jun 9, 2017

Closing as it's fixed at HEAD, and will release with 4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.