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

@ -654,7 +654,7 @@ export function inject(tokens: any[], fn: Function): () => any {
const testBed = getTestBed();
if (tokens.indexOf(AsyncTestCompleter) >= 0) {
// Not using an arrow function to preserve context passed from call site
return function() {
return function(this: unknown) {
// Return an async test method that returns a Promise if AsyncTestCompleter is one of
// the injected tokens.
return testBed.compileComponents().then(() => {
@ -665,7 +665,7 @@ export function inject(tokens: any[], fn: Function): () => any {
};
} else {
// Not using an arrow function to preserve context passed from call site
return function() { return testBed.execute(tokens, fn, this); };
return function(this: unknown) { return testBed.execute(tokens, fn, this); };
}
}
@ -685,7 +685,7 @@ export class InjectSetupWrapper {
inject(tokens: any[], fn: Function): () => any {
const self = this;
// Not using an arrow function to preserve context passed from call site
return function() {
return function(this: unknown) {
self._addModule();
return inject(tokens, fn).call(this);
};
@ -701,7 +701,7 @@ export function withModule(moduleDef: TestModuleMetadata, fn?: Function | null):
InjectSetupWrapper {
if (fn) {
// Not using an arrow function to preserve context passed from call site
return function() {
return function(this: unknown) {
const testBed = getTestBed();
if (moduleDef) {
testBed.configureTestingModule(moduleDef);