refactor: add types (#9116)
This commit is contained in:

committed by
Miško Hevery

parent
b60eecfc47
commit
7ce0fc7d47
@ -64,7 +64,7 @@ class HelloRootCmp3 {
|
||||
class HelloRootCmp4 {
|
||||
appRef: any /** TODO #9100 */;
|
||||
|
||||
constructor(@Inject(ApplicationRef) appRef: any /** TODO #9100 */) { this.appRef = appRef; }
|
||||
constructor(@Inject(ApplicationRef) appRef: ApplicationRef) { this.appRef = appRef; }
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app'})
|
||||
@ -78,7 +78,7 @@ class HelloRootDirectiveIsNotCmp {
|
||||
@Component({selector: 'hello-app', template: ''})
|
||||
class HelloOnDestroyTickCmp implements OnDestroy {
|
||||
appRef: ApplicationRef;
|
||||
constructor(@Inject(ApplicationRef) appRef: any /** TODO #9100 */) { this.appRef = appRef; }
|
||||
constructor(@Inject(ApplicationRef) appRef: ApplicationRef) { this.appRef = appRef; }
|
||||
|
||||
ngOnDestroy(): void { this.appRef.tick(); }
|
||||
}
|
||||
@ -129,7 +129,7 @@ export function main() {
|
||||
expect(logger.res.join("")).toContain("Could not compile");
|
||||
});
|
||||
|
||||
it('should throw if no element is found', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
it('should throw if no element is found', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var logger = new _ArrayLogger();
|
||||
var exceptionHandler = new ExceptionHandler(logger, false);
|
||||
|
||||
@ -144,7 +144,7 @@ export function main() {
|
||||
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
it('should forward the error to promise when bootstrap fails',
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
// Skip for dart since it causes a confusing error message in console when test passes.
|
||||
var logger = new _ArrayLogger();
|
||||
var exceptionHandler = new ExceptionHandler(logger, false);
|
||||
@ -159,7 +159,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should invoke the default exception handler when bootstrap fails',
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var logger = new _ArrayLogger();
|
||||
var exceptionHandler = new ExceptionHandler(logger, false);
|
||||
|
||||
@ -179,7 +179,7 @@ export function main() {
|
||||
expect(refPromise).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should display hello world', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
it('should display hello world', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise = bootstrap(HelloRootCmp, testProviders);
|
||||
refPromise.then((ref) => {
|
||||
expect(el).toHaveText('hello world!');
|
||||
@ -187,7 +187,7 @@ export function main() {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should support multiple calls to bootstrap', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
it('should support multiple calls to bootstrap', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise1 = bootstrap(HelloRootCmp, testProviders);
|
||||
var refPromise2 = bootstrap(HelloRootCmp2, testProviders);
|
||||
PromiseWrapper.all([refPromise1, refPromise2])
|
||||
@ -199,7 +199,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should not crash if change detection is invoked when the root component is disposed',
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
bootstrap(HelloOnDestroyTickCmp, testProviders)
|
||||
.then((ref) => {
|
||||
expect(() => ref.destroy()).not.toThrow();
|
||||
@ -208,7 +208,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should unregister change detectors when components are disposed',
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var platform = createPlatform(ReflectiveInjector.resolveAndCreate(BROWSER_PLATFORM_PROVIDERS));
|
||||
var app =
|
||||
ReflectiveInjector.resolveAndCreate([BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS, testProviders],
|
||||
@ -223,7 +223,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it("should make the provided bindings available to the application component",
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise = bootstrap(
|
||||
HelloRootCmp3, [testProviders, {provide: "appBinding", useValue: "BoundValue"}]);
|
||||
|
||||
@ -234,7 +234,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it("should avoid cyclic dependencies when root component requires Lifecycle through DI",
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise = bootstrap(HelloRootCmp4, testProviders);
|
||||
|
||||
refPromise.then((ref) => {
|
||||
@ -264,7 +264,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should register each application with the testability registry',
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
var refPromise1: Promise<ComponentRef<any>> = bootstrap(HelloRootCmp, testProviders);
|
||||
var refPromise2: Promise<ComponentRef<any>> = bootstrap(HelloRootCmp2, testProviders);
|
||||
|
||||
|
@ -123,7 +123,7 @@ export function main() {
|
||||
beforeEachProviders(() => [{provide: FancyService, useValue: new FancyService()}]);
|
||||
|
||||
it('provides a real XHR instance',
|
||||
inject([XHR], (xhr: any /** TODO #9100 */) => { expect(xhr).toBeAnInstanceOf(XHRImpl); }));
|
||||
inject([XHR], (xhr: XHR) => { expect(xhr).toBeAnInstanceOf(XHRImpl); }));
|
||||
|
||||
it('should allow the use of fakeAsync', fakeAsync(inject([FancyService], (service: any /** TODO #9100 */) => {
|
||||
var value: any /** TODO #9100 */;
|
||||
@ -156,7 +156,7 @@ export function main() {
|
||||
|
||||
it('should fail with an error from a promise',
|
||||
async(inject([TestComponentBuilder],
|
||||
(tcb: any /** TODO #9100 */) => { return tcb.createAsync(BadTemplateUrl); })));
|
||||
(tcb: TestComponentBuilder) => { return tcb.createAsync(BadTemplateUrl); })));
|
||||
|
||||
itPromise.then(() => { done.fail('Expected test to fail, but it did not'); }, (err) => {
|
||||
expect(err).toEqual('Uncaught (in promise): Failed to load non-existant.html');
|
||||
|
@ -24,7 +24,7 @@ export function main() {
|
||||
beforeEach(() => { bus = createConnectedMessageBus(); });
|
||||
|
||||
it("should pass messages in the same channel from sink to source",
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const CHANNEL = "CHANNEL 1";
|
||||
const MESSAGE = "Test message";
|
||||
bus.initChannel(CHANNEL, false);
|
||||
@ -38,7 +38,7 @@ export function main() {
|
||||
ObservableWrapper.callEmit(toEmitter, MESSAGE);
|
||||
}));
|
||||
|
||||
it("should broadcast", inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
it("should broadcast", inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const CHANNEL = "CHANNEL 1";
|
||||
const MESSAGE = "TESTING";
|
||||
const NUM_LISTENERS = 2;
|
||||
@ -62,7 +62,7 @@ export function main() {
|
||||
ObservableWrapper.callEmit(toEmitter, MESSAGE);
|
||||
}));
|
||||
|
||||
it("should keep channels independent", inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
it("should keep channels independent", inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
const CHANNEL_ONE = "CHANNEL 1";
|
||||
const CHANNEL_TWO = "CHANNEL 2";
|
||||
const MESSAGE_ONE = "This is a message on CHANNEL 1";
|
||||
@ -114,7 +114,7 @@ export function main() {
|
||||
it("should buffer messages and wait for the zone to exit before sending",
|
||||
withProviders(() => [{provide: NgZone, useClass: MockNgZone}])
|
||||
.inject([AsyncTestCompleter, NgZone],
|
||||
(async: any /** TODO #9100 */, zone: MockNgZone) => {
|
||||
(async: AsyncTestCompleter, zone: MockNgZone) => {
|
||||
bus = createConnectedMessageBus();
|
||||
setup(true, zone);
|
||||
|
||||
@ -137,7 +137,7 @@ export function main() {
|
||||
500);
|
||||
|
||||
it("should send messages immediatly when run outside the zone",
|
||||
inject([AsyncTestCompleter, NgZone], (async: any /** TODO #9100 */, zone: MockNgZone) => {
|
||||
inject([AsyncTestCompleter, NgZone], (async: AsyncTestCompleter, zone: MockNgZone) => {
|
||||
bus = createConnectedMessageBus();
|
||||
setup(false, zone);
|
||||
|
||||
|
@ -38,7 +38,7 @@ export function main() {
|
||||
messageBuses.worker.initChannel(CHANNEL);
|
||||
});
|
||||
it("should call registered method with correct arguments",
|
||||
inject([Serializer], (serializer: any /** TODO #9100 */) => {
|
||||
inject([Serializer], (serializer: Serializer) => {
|
||||
var broker = new ServiceMessageBroker_(messageBuses.ui, serializer, CHANNEL);
|
||||
broker.registerMethod(TEST_METHOD, [PRIMITIVE, PRIMITIVE], (arg1, arg2) => {
|
||||
expect(arg1).toEqual(PASSED_ARG_1);
|
||||
@ -51,7 +51,7 @@ export function main() {
|
||||
// TODO(pkozlowski): this fails only in Edge with
|
||||
// "No provider for RenderStore! (Serializer -> RenderStore)"
|
||||
if (!browserDetection.isEdge) {
|
||||
it("should return promises to the worker", inject([Serializer], (serializer: any /** TODO #9100 */) => {
|
||||
it("should return promises to the worker", inject([Serializer], (serializer: Serializer) => {
|
||||
var broker = new ServiceMessageBroker_(messageBuses.ui, serializer, CHANNEL);
|
||||
broker.registerMethod(TEST_METHOD, [PRIMITIVE], (arg1) => {
|
||||
expect(arg1).toEqual(PASSED_ARG_1);
|
||||
|
@ -81,7 +81,7 @@ export function main() {
|
||||
expect(() => platformLocation.pathname = "TEST").toThrowError();
|
||||
});
|
||||
|
||||
it("should send pathname to render thread", inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
it("should send pathname to render thread", inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
let platformLocation = createWebWorkerPlatformLocation(TEST_LOCATION);
|
||||
platformLocation.init().then((_) => {
|
||||
let PATHNAME = "/test";
|
||||
|
@ -100,7 +100,7 @@ export function main() {
|
||||
{provide: RenderStore, useValue: workerRenderStore},
|
||||
{
|
||||
provide: RootRenderer,
|
||||
useFactory: (workerSerializer: any /** TODO #9100 */) => {
|
||||
useFactory: (workerSerializer: Serializer) => {
|
||||
return createWorkerRenderer(workerSerializer, uiSerializer, domRootRenderer,
|
||||
uiRenderStore, workerRenderStore);
|
||||
},
|
||||
@ -119,7 +119,7 @@ export function main() {
|
||||
}
|
||||
|
||||
it('should update text nodes',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({template: '<div>{{ctxProp}}</div>'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
@ -135,7 +135,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should update any element property/attributes/class/style(s) independent of the compilation on the root element and other elements',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata(
|
||||
{template: '<input [title]="y" style="position:absolute">'}))
|
||||
.createAsync(MyComp2)
|
||||
@ -170,7 +170,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should update any template comment property/attributes',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
var tpl = '<template [ngIf]="ctxBoolProp"></template>';
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({template: tpl, directives: [NgIf]}))
|
||||
|
||||
@ -185,7 +185,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should add and remove fragments',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({
|
||||
template: '<template [ngIf]="ctxBoolProp">hello</template>',
|
||||
directives: [NgIf]
|
||||
@ -210,7 +210,7 @@ export function main() {
|
||||
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
it('should call actions on the element',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2, new ViewMetadata({template: '<input [title]="y">'}))
|
||||
.createAsync(MyComp2)
|
||||
.then((fixture) => {
|
||||
@ -225,7 +225,7 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should listen to events',
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: any /** TODO #9100 */) => {
|
||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
||||
tcb.overrideView(MyComp2,
|
||||
new ViewMetadata({template: '<input (change)="ctxNumProp = 1">'}))
|
||||
.createAsync(MyComp2)
|
||||
|
@ -43,7 +43,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should resolve the Promise with the cached file content on success',
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
setTemplateCache({'test.html': '<div>Hello</div>'});
|
||||
xhr = new CachedXHR();
|
||||
xhr.get('test.html')
|
||||
@ -53,7 +53,7 @@ export function main() {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should reject the Promise on failure', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
it('should reject the Promise on failure', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
xhr = new CachedXHR();
|
||||
xhr.get('unknown.html')
|
||||
.then((text) => { throw new BaseException('Not expected to succeed.'); })
|
||||
|
@ -28,14 +28,14 @@ export function main() {
|
||||
beforeEach(() => { xhr = new XHRImpl(); });
|
||||
|
||||
it('should resolve the Promise with the file content on success',
|
||||
inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
xhr.get(url200).then((text) => {
|
||||
expect(text.trim()).toEqual('<p>hey</p>');
|
||||
async.done();
|
||||
});
|
||||
}), 10000);
|
||||
|
||||
it('should reject the Promise on failure', inject([AsyncTestCompleter], (async: any /** TODO #9100 */) => {
|
||||
it('should reject the Promise on failure', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||
PromiseWrapper.catchError(xhr.get(url404), (e) => {
|
||||
expect(e).toEqual(`Failed to load ${url404}`);
|
||||
async.done();
|
||||
|
Reference in New Issue
Block a user