Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

5.0.0-alpha+6

Choose a tag to compare

@alorenzen alorenzen released this 27 Feb 03:25
· 2048 commits to master since this release

angular

5.0.0-alpha+6

New features

  • The compiler now reports an actionable error when an annotation is used on a
    private class member.

  • Added InjectionError and NoProviderError, which may be thrown during
    dependency injection when InjectionError.enableBetterErrors is set to
    true. This is an experiment, and we may not complete this feature (and it
    could be rolled back entirely).

  • Added @GenerateInjector, a way to generate a factory for an Injector
    completely at compile-time, similar to @Component or @Directive. This
    replaces the experimental feature @Injector.generate, and can be used in
    conjunction with the InjectorFactory function type:

import 'my_file.template.dart' as ng;

@GenerateInjector(const [
  const Provider(A, useClass: APrime),
])
// The generated factory is your method's name, suffixed with `$Injector`.
final InjectorFactory example = example$Injector;
  • You are now able to use an OpaqueToken or MultiToken as an annotation
    directly instead of wrapping it in @Inject. For example, the following
    classes are identically understood by AngularDart:
const baseUrl = const OpaqueToken<String>('baseUrl');

class Comp1 {
  Comp1(@Inject(baseUrl) String url);
}

class Comp2 {
  Comp2(@baseUrl String url);
}
  • You are now able to extend OpaqueToken or MulitToken to provide
    custom application-specific injection tokens. For example, providing a
    specific token for XSRF purposes:
class XsrfToken extends OpaqueToken<String> {
  const XsrfToken();
}

@Component(
  providers: const [
    const ValueProvider.forToken(const XsrfToken(), 'ABC123'),
  ],
)
class Comp {
  Comp(@XsrfToken() String token) {
    print(token); // ABC123
  }
}

Breaking changes

  • Restricted the default visibility of all components and directives to
    Visibility.local. This means components and directives will no longer be
    available for injection by their descendants, unless their visibility is
    explicitly set to Visibility.all. This feature had a cost in code size but
    was rarely used, so it's now opt-in, rather than the default behavior.

  • We now use a different code-path for the majority of content and view
    queries, with the exception of places statically typed QueryList. While
    this is not intended to be a breaking change it could have timing
    implications.

  • Both COMMON_DIRECTIVES and CORE_DIRECTIVES are now deprecated, and
    should be replaced by coreDirectives. This is a no-op change (alias).

  • Removed the deprecated EventEmitter class from the public entrypoints.

Bug fixes

  • An invalid event binding (<comp (event-with-no-expression)>) no longer
    crashes the parser during compilation and instead reports that such a
    binding is not allowed.

  • Corrects the behavior of Visibility.local to match documentation.

    Previously, a directive with Visibility.local was only injectable via an
    alias within its defining view. This meant the following was possible

    abstract class Dependency {}
    
    @Component(
      selector: 'dependency',
      template: '<ng-content></ng-content>',
      providers: const [
        const Provider(Dependency, useExisting: DependencyImpl),
      ],
      visibility: Visibility.local,
    )
    class DependencyImpl implements Dependency {}
    
    @Component(
      selector: 'dependent',
      ...
    )
    class Dependent {
      Dependent(Dependency _); // Injection succeeds.
    }
    
    @Component(
      selector: 'app',
      template: '''
        <dependency>
          <dependent></dependent>
        </dependency>
      ''',
      directives: const [Dependency, Dependent],
    )
    class AppComponent {}

    because both DependencyImpl and Dependent are constructed in the same
    method, thus the instance of DependencyImpl could be passed directly to
    Dependent without an injector lookup. However, the following failed

    @Component(
      selector: 'dependency',
      // `Dependent` will fail to inject `Dependency`.
      template: '<dependent></dependent>',
      directives: const [Dependent],
      providers: const [
        const Provider(Dependency, useExisting: DependencyImpl),
      ],
      visibility: Visibility.local,
    )
    class DependencyImpl implements Dependency {}

    because no code was generated for children to inject Dependency. This was
    at odds with the documentation, and optimized for a very specific use case.

    This has been fixed and it's now possible for all children of
    DependencyImpl to inject Dependency, not just those constructed in the
    same view.

  • Services that were not marked @Injectable() are no longer skipped when
    provided in providers: const [ ... ] for a @Directive or @Component.
    This choice made sense when @Injectable() was required, but this is no
    longer the case. Additionally, the warning that was printed to console has
    been removed.

  • It is no longer a build warning to have an injectable service with multiple
    constructors. This was originally meant to keep injection from being too
    ambiguous, but there are understood patterns now (first constructor), and
    there is no alternative present yet. We may re-add this as a warning if
    there ends up being a mechanism to pick a constructor in the future.

  • It is no longer a build warning to have injectable services or components
    with named constructor parameters. While they are still not supported for
    injected, they were always successfully ignored in the past, and showing a
    warning to the user on every build served no purpose.

  • If a templateUrl is mispelled, a more readable exception is thrown (closes
    #389):

    [SEVERE]: Unable to read file:
      "package:.../not_a_template.html"
      Ensure the file exists on disk and is available to the compiler.
  • If both template AND templateUrl are supplied, it is now a cleaner build
    error (closes #451):

    [SEVERE]: Component "CompWithBothProperties" in
      asset:experimental.users.matanl.examples.angular.template_url_crash/lib/template_url_crash.dart:
      Cannot supply both "template" and "templateUrl"
  • If neither is supplied, it is also a cleaner build error:

    [SEVERE]: Component "CompWithNoTemplate" in
      asset:experimental.users.matanl.examples.angular.template_url_crash/lib/template_url_crash.dart:
      Requires either a "template" or "templateUrl"; had neither.
  • If a template is a string that points to a file on disk, we now warn:

    [WARNING]: Component "CompMeantTemplateUrl" in
      asset:experimental.users.matanl.examples.angular.template_url_crash/lib/template_url_crash.dart:
      Has a "template" property set to a string that is a file.
      This is a common mistake, did you mean "templateUrl" instead?
  • If a private class is annotated with @Injectable() the compiler fails. In
    practice this caused a compilation error later in DDC/Dart2JS, but now the
    AngularDart compiler will not emit invalid code.

  • Removed spurious/incorrect warnings about classes that are used as
    interfaces needing @Injectable (or needing to be non-abstract), which
    are wrong and confusing.

  • Fixed a case where the compiler generated incorrect code when a directive D
    was applied to the host element of component C where

    • C implements D,
    • C provides D as an alias for itself, and
    • C has Visibility.local.

    Normally the local reference for C would be reused instead of creating a new
    D. Giving C local visibility incorrectly prevented this assignment and
    generated code to inject D from the parent injector.

  • Fixed a bug where Provider<List<T>> was treated as Provider<List> when
    compiled as part of the view compiler (@Component.providers:). Now the
    additional generic types flow through the compiler.

  • Fixed a case where provider fields weren't type annotated. In some cases
    this led to DDC warnings that are to become errors.

  • The code generated for injecting a multi-token will now correctly inject a
    provider that uses an existing directive with Visibility.local. This
    previously failed if another existing directive with Visibility.all was
    provided for the same multi-token, after the one with Visibility.local.

angular_router

2.0.0-alpha+6

New features

  • Router.onNavigationStart now emits the requested navigation path.

angular_forms

1.0.1-alpha+6

New features

  • Add markAsUntouched method to AbstractControl.
  • Add a type annotation, T, to AbstractControl, which is tied to the type
    of value.
  • ControlGroup now extends AbstractControl<Map<String, dynamic>>.
  • ControlArray now extends AbstractControl<List>.

Breaking Changes

  • Changed type of AbstractControl.statusChanges from Stream<dynamic> to
    Stream<String>. This now matches the type for AbstractControl.status,
    which as always been a String.

Deprecations

  • FormBuilder instance methods group, control, and array are now
    deprecated. For FormBuilder.control, just call new Control(value, validator) directly. For FormBuilder.group and FormBuilder.array, use
    the static methods FormBuilder.controlGroup and FormBuilder.controlArray
    respectively. In a future release, FormBuilder will not not be
    Injectable.

angular_test

2.0.0-alpha+4

  • Removed built-in support for package:pageloader. The current version of
    pageloader relies on dart:mirrors, which is being removed from the web
    compilers (dart2js, dartdevc). There is a new (internal-only, right now)
    version of pageloader in development that uses code generation, but it is
    not available externally yet. We'll consider re-adding support once
    available or through another package (i.e. angular_pageloader or similar).

  • Added NgTestBed.forComponent, which takes a ComponentFactory<T>, and
    optionally an InjectorFactory. This allows writing tests entirely free of
    any invocations of initReflector().

  • BREAKING CHANGE: Adding stabilizers to NgTestBed now takes a factory
    function of type NgTestStabilizer Function(Injector), which is aliased as
    NgTestStabilizerFactory. This allows using NgTestBed without any dynamic
    reflective factories (i.e. initReflector()) and doesn't have impact to
    most users.

angular_compiler

0.4.0-alpha+6

New features

  • Added an internal cli.dart library. See lib/cli.dart for details.
  • Added SplitDartEmitter for internal use.
  • Added $QueryList as a TypeChecker.
  • Expose the $Provider TypeChecker.

Bug fixes

  • Removed all remaining (invalid) references to package:barback.

Breaking changes

  • Added canRead to NgAssetReader.
  • Moved CompilerFlags and Profile to cli.dart.