refactor(core): ensure compatibility with typescript strict flag (#30993)

As part of FW-1265, the `@angular/core` package is made compatible
with the TypeScript `--strict` flag. This already unveiled a few bugs,
so the strictness flag seems to help with increasing the overall code health.

Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html)

PR Close #30993
This commit is contained in:
Paul Gschwendtner
2019-06-14 09:27:41 +02:00
committed by Miško Hevery
parent 78e7fdd98d
commit 2200884e55
29 changed files with 122 additions and 86 deletions

View File

@ -36,7 +36,7 @@ export function asyncFallback(fn: Function): (done: any) => any {
// function when asynchronous activity is finished.
if (_global.jasmine) {
// Not using an arrow function to preserve context passed from call site
return function(done: any) {
return function(this: unknown, done: any) {
if (!done) {
// if we run beforeEach in @angular/core/testing/testing_internal then we get no done
// fake it here and assume sync.
@ -56,7 +56,7 @@ export function asyncFallback(fn: Function): (done: any) => any {
// is finished. This will be correctly consumed by the Mocha framework with
// it('...', async(myFn)); or can be used in a custom framework.
// Not using an arrow function to preserve context passed from call site
return function() {
return function(this: unknown) {
return new Promise<void>((finishCallback, failCallback) => {
runInTestZone(fn, this, finishCallback, failCallback);
});