From a27c5dd7400f57aaaa7c622b016fd41a2e6161bc Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 14 Jun 2019 09:29:04 +0200 Subject: [PATCH] refactor: fix remaining typescript strict flag failures (#30993) Fixes the remaining TypeScript --strict flag failures for source files which are not part of any specific release package. PR Close #30993 --- .../src/expanding_rows/expanding_row_host.ts | 2 +- .../examples/common/pipes/ts/async_pipe.ts | 5 ++-- packages/http/BUILD.bazel | 3 ++ packages/platform-webworker/BUILD.bazel | 3 ++ packages/tsconfig.json | 28 +++++++++++-------- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/modules/benchmarks/src/expanding_rows/expanding_row_host.ts b/modules/benchmarks/src/expanding_rows/expanding_row_host.ts index 28a6ed15f93be..52bf88ecb8f52 100644 --- a/modules/benchmarks/src/expanding_rows/expanding_row_host.ts +++ b/modules/benchmarks/src/expanding_rows/expanding_row_host.ts @@ -112,7 +112,7 @@ export class ExpandingRowHost implements AfterViewInit, * function around. This enables us to detach the click listener when * component is destroyed. */ - private handleRootMouseUpBound: EventListenerObject = this.handleRootMouseUp.bind(this); + private handleRootMouseUpBound = this.handleRootMouseUp.bind(this); /** * 16px is the margin animation we have on cfc-expanding-row component. diff --git a/packages/examples/common/pipes/ts/async_pipe.ts b/packages/examples/common/pipes/ts/async_pipe.ts index 50eb38ae01fba..c1a6028f1fc50 100644 --- a/packages/examples/common/pipes/ts/async_pipe.ts +++ b/packages/examples/common/pipes/ts/async_pipe.ts @@ -63,6 +63,7 @@ function setInterval(fn: Function, delay: number) { while (rootZone.parent) { rootZone = rootZone.parent; } - rootZone.run( - () => { window.setInterval(function() { zone.run(fn, this, arguments as any); }, delay); }); + rootZone.run(() => { + window.setInterval(function(this: unknown) { zone.run(fn, this, arguments as any); }, delay); + }); } diff --git a/packages/http/BUILD.bazel b/packages/http/BUILD.bazel index 94a4ba0e694b9..c85c41761f57d 100644 --- a/packages/http/BUILD.bazel +++ b/packages/http/BUILD.bazel @@ -10,6 +10,9 @@ ng_module( "src/**/*.ts", ], ), + # Disable building with strict compatibility as the http package is no longer + # maintained and therefore not needed to be made compatible with --strict. + tsconfig = "//packages:tsconfig-build-no-strict", deps = [ "//packages/core", "//packages/platform-browser", diff --git a/packages/platform-webworker/BUILD.bazel b/packages/platform-webworker/BUILD.bazel index 47f4e2c94ab64..d1e66e309622b 100644 --- a/packages/platform-webworker/BUILD.bazel +++ b/packages/platform-webworker/BUILD.bazel @@ -10,6 +10,9 @@ ng_module( "src/**/*.ts", ], ), + # Disable building with strict compatibility as the platform-webworker package is + # deprecated and therefore it is not needed to make it compatible with --strict. + tsconfig = "//packages:tsconfig-build-no-strict", deps = [ "//packages:types", "//packages/common", diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 516d3ee95ac48..3b67f9672b6ef 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -1,6 +1,8 @@ { "compilerOptions": { - "baseUrl": ".", + // Setting the "baseUrl" to a different directory than "packages/" because otherwise + // packages like the native "http" module are resolved to the Angular "http" package. + "baseUrl": "..", "declaration": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, @@ -12,10 +14,10 @@ "noImplicitAny": true, "noFallthroughCasesInSwitch": true, "paths": { - "selenium-webdriver": ["../node_modules/@types/selenium-webdriver/index.d.ts"], - "rxjs/*": ["../node_modules/rxjs/*"], - "@angular/*": ["./*"], - "e2e_util/*": ["../modules/e2e_util/*"] + "selenium-webdriver": ["./node_modules/@types/selenium-webdriver/index.d.ts"], + "rxjs/*": ["./node_modules/rxjs/*"], + "@angular/*": ["./packages/*"], + "e2e_util/*": ["./modules/e2e_util/*"] }, "rootDir": ".", "inlineSourceMap": true, @@ -34,13 +36,17 @@ "compiler-cli/integrationtest", "core/schematics", "elements/schematics", - // Do not build the example e2e spec files since those require custom typings and - // aren't required to build all packages. - "examples/**/e2e_test/*", - // Exclude the "main.ts" files for each example group because this file is used by - // Bazel to launch the devserver and uses AOT compilation. - "examples/**/main.ts", + // Do not build the example package because there are no legacy tests that need to be + // built. Additionally the examples are not made compatible with the "strict" option. + "examples/**", + // Http doesn't need to built since it is no longer maintained and + // will be removed eventually. See: FW-1392. + "http/**", "platform-server/integrationtest", + // The webworker packages have deprecated and are not made compatible with the + // strict flag. Until these packages are removed, we exclude them here. + "platform-webworker/**", + "platform-webworker-dynamic/**", "router/test/aot_ngsummary_test", "zone.js" ]