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:

committed by
Miško Hevery

parent
78e7fdd98d
commit
2200884e55
@ -92,10 +92,10 @@ export interface InjectableType<T> extends Type<T> { ngInjectableDef: ɵɵInject
|
||||
* Supports @Injectable() in JIT mode for Render2.
|
||||
*/
|
||||
function render2CompileInjectable(
|
||||
injectableType: InjectableType<any>,
|
||||
options: {providedIn?: Type<any>| 'root' | null} & InjectableProvider): void {
|
||||
injectableType: Type<any>,
|
||||
options?: {providedIn?: Type<any>| 'root' | null} & InjectableProvider): void {
|
||||
if (options && options.providedIn !== undefined && !getInjectableDef(injectableType)) {
|
||||
injectableType.ngInjectableDef = ɵɵdefineInjectable({
|
||||
(injectableType as InjectableType<any>).ngInjectableDef = ɵɵdefineInjectable({
|
||||
token: injectableType,
|
||||
providedIn: options.providedIn,
|
||||
factory: convertInjectableProviderToFactory(injectableType, options),
|
||||
|
@ -68,8 +68,8 @@ export function setCurrentInjector(injector: Injector | null | undefined): Injec
|
||||
* 1. `Injector` should not depend on ivy logic.
|
||||
* 2. To maintain tree shake-ability we don't want to bring in unnecessary code.
|
||||
*/
|
||||
let _injectImplementation: (<T>(token: Type<T>| InjectionToken<T>, flags: InjectFlags) => T | null)|
|
||||
undefined;
|
||||
let _injectImplementation:
|
||||
(<T>(token: Type<T>| InjectionToken<T>, flags?: InjectFlags) => T | null)|undefined;
|
||||
|
||||
/**
|
||||
* Sets the current inject implementation.
|
||||
|
@ -180,10 +180,11 @@ export function mergeResolvedReflectiveProviders(
|
||||
return normalizedProvidersMap;
|
||||
}
|
||||
|
||||
function _normalizeProviders(providers: Provider[], res: Provider[]): Provider[] {
|
||||
function _normalizeProviders(
|
||||
providers: Provider[], res: NormalizedProvider[]): NormalizedProvider[] {
|
||||
providers.forEach(b => {
|
||||
if (b instanceof Type) {
|
||||
res.push({provide: b, useClass: b});
|
||||
res.push({ provide: b, useClass: b } as NormalizedProvider);
|
||||
|
||||
} else if (b && typeof b == 'object' && (b as any).provide !== undefined) {
|
||||
res.push(b as NormalizedProvider);
|
||||
|
Reference in New Issue
Block a user