From 5bd12c5aa113b0da88c73e51be748766f374911f Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 13 Jun 2019 20:12:43 +0200 Subject: [PATCH] refactor(upgrade): ensure compatibility with typescript strict flag (#30993) As part of FW-1265, the `@angular/upgrade` package is made compatible with the TypeScript `--strict` flag. Read more about the strict flag [here](https://www.typescriptlang.org/docs/handbook/compiler-options.html) PR Close #30993 --- packages/upgrade/src/common/src/angular1.ts | 4 +--- .../upgrade/src/common/test/helpers/common_test_helpers.ts | 2 +- packages/upgrade/src/dynamic/src/upgrade_adapter.ts | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/upgrade/src/common/src/angular1.ts b/packages/upgrade/src/common/src/angular1.ts index efe8d0bd59..9615a3c927 100644 --- a/packages/upgrade/src/common/src/angular1.ts +++ b/packages/upgrade/src/common/src/angular1.ts @@ -116,9 +116,7 @@ export interface ITranscludeFunction { // If one argument is provided, then it's assumed to be the cloneAttachFn. (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; } -export interface ICloneAttachFunction { - (clonedElement: IAugmentedJQuery, scope: IScope): any; -} +export interface ICloneAttachFunction { (clonedElement: IAugmentedJQuery, scope: IScope): any; } export type IAugmentedJQuery = Node[] & { on?: (name: string, fn: () => void) => void; data?: (name: string, value?: any) => any; diff --git a/packages/upgrade/src/common/test/helpers/common_test_helpers.ts b/packages/upgrade/src/common/test/helpers/common_test_helpers.ts index 209d4304bc..436f6261d9 100644 --- a/packages/upgrade/src/common/test/helpers/common_test_helpers.ts +++ b/packages/upgrade/src/common/test/helpers/common_test_helpers.ts @@ -124,7 +124,7 @@ export function createWithEachNg1VersionFn(setNg1: typeof setAngularJSGlobal) { delete win.angular; }); - methodsToPatch.forEach(method => win[method](function() { + methodsToPatch.forEach(method => win[method](function(this: unknown) { // Run the captured callbacks. (Async callbacks not supported.) methodCallbacks[method].forEach(cb => cb.call(this)); })); diff --git a/packages/upgrade/src/dynamic/src/upgrade_adapter.ts b/packages/upgrade/src/dynamic/src/upgrade_adapter.ts index ff35f0a1c2..4232b2690f 100644 --- a/packages/upgrade/src/dynamic/src/upgrade_adapter.ts +++ b/packages/upgrade/src/dynamic/src/upgrade_adapter.ts @@ -537,8 +537,8 @@ export class UpgradeAdapter { function(testabilityDelegate: ITestabilityService) { const originalWhenStable: Function = testabilityDelegate.whenStable; // Cannot use arrow function below because we need the context - const newWhenStable = function(callback: Function) { - originalWhenStable.call(this, function() { + const newWhenStable = function(this: unknown, callback: Function) { + originalWhenStable.call(this, function(this: unknown) { const ng2Testability: Testability = upgradeAdapter.moduleRef !.injector.get(Testability); if (ng2Testability.isStable()) { @@ -670,7 +670,7 @@ class ParentInjectorPromise { */ export class UpgradeAdapterRef { /* @internal */ - private _readyFn: ((upgradeAdapterRef?: UpgradeAdapterRef) => void)|null = null; + private _readyFn: ((upgradeAdapterRef: UpgradeAdapterRef) => void)|null = null; public ng1RootScope: IRootScopeService = null !; public ng1Injector: IInjectorService = null !;