feat(di): drop support for injecting types with generics in Dart
BREAKING CHANGE: In Dart we used to support injecting types with generics. As this feature is hard to implement with the upcoming codegen we are dropping it. Merge cl/115454020 in G3 with this change. Closes #7262
This commit is contained in:
@ -1,22 +0,0 @@
|
||||
/// This file contains tests that make sense only in Dart
|
||||
library angular2.test.di.injector_dart_spec;
|
||||
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
import 'package:angular2/core.dart';
|
||||
|
||||
main() {
|
||||
describe('Injector', () {
|
||||
it('should support TypeLiteral', () {
|
||||
var i = Injector.resolveAndCreate([
|
||||
bind(new TypeLiteral<List<int>>()).toValue([1, 2, 3]),
|
||||
Foo,
|
||||
]);
|
||||
expect(i.get(Foo).value).toEqual([1, 2, 3]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class Foo {
|
||||
final List<int> value;
|
||||
Foo(this.value);
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/// This file contains tests that make sense only in Dart
|
||||
library angular2.test.di.key_dart_spec;
|
||||
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
import 'package:angular2/core.dart';
|
||||
import 'package:angular2/src/core/di/key.dart';
|
||||
|
||||
main() {
|
||||
describe('TypeLiteral', () {
|
||||
it('contains type', () {
|
||||
var t = new TypeLiteral<List<int>>();
|
||||
expect('${t.type}').toEqual('List<int>');
|
||||
});
|
||||
|
||||
it('can be a constant', () {
|
||||
var a = const TypeLiteral<List<int>>();
|
||||
var b = const TypeLiteral<List<int>>();
|
||||
expect(identical(a, b)).toBe(true);
|
||||
});
|
||||
|
||||
it('can be unique', () {
|
||||
var a = const TypeLiteral<List<String>>();
|
||||
var b = const TypeLiteral<List<int>>();
|
||||
expect(identical(a, b)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Key', () {
|
||||
KeyRegistry registry;
|
||||
|
||||
beforeEach(() {
|
||||
registry = new KeyRegistry();
|
||||
});
|
||||
|
||||
it('understands TypeLiteral', () {
|
||||
var k = registry.get(const TypeLiteral<List<int>>());
|
||||
expect('${k.token}').toEqual('List<int>');
|
||||
});
|
||||
});
|
||||
}
|
@ -42,27 +42,6 @@ void functionThatThrowsNonError() {
|
||||
}
|
||||
|
||||
main() {
|
||||
describe('TypeLiteral', () {
|
||||
it(
|
||||
'should publish via viewBindings',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tb, async) {
|
||||
tb
|
||||
.overrideView(
|
||||
Dummy,
|
||||
new ViewMetadata(
|
||||
template:
|
||||
'<type-literal-component></type-literal-component>',
|
||||
directives: [TypeLiteralComponent]))
|
||||
.createAsync(Dummy)
|
||||
.then((tc) {
|
||||
tc.detectChanges();
|
||||
expect(asNativeElements(tc.debugElement.children))
|
||||
.toHaveText('[Hello, World]');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('Error handling', () {
|
||||
it(
|
||||
'should preserve Error stack traces thrown from components',
|
||||
@ -216,19 +195,6 @@ class Dummy {
|
||||
dynamic value;
|
||||
}
|
||||
|
||||
@Component(
|
||||
selector: 'type-literal-component',
|
||||
viewBindings: const [
|
||||
const Binding(const TypeLiteral<List<String>>(),
|
||||
toValue: const <String>['Hello', 'World'])
|
||||
])
|
||||
@View(template: '{{list}}')
|
||||
class TypeLiteralComponent {
|
||||
final List<String> list;
|
||||
|
||||
TypeLiteralComponent(this.list);
|
||||
}
|
||||
|
||||
@Component(selector: 'throwing-component')
|
||||
@View(template: '')
|
||||
class ThrowingComponent {
|
||||
|
@ -1313,8 +1313,6 @@ var NG_CORE = [
|
||||
'GetTestability:dart',
|
||||
'setTestabilityGetter()',
|
||||
'Type:js',
|
||||
'TypeLiteral',
|
||||
'TypeLiteral.type',
|
||||
'PACKAGE_ROOT_URL',
|
||||
'View',
|
||||
'View.directives',
|
||||
|
Reference in New Issue
Block a user