From 29c44ca9939e14a1252bd57766b7bdbf53dd745c Mon Sep 17 00:00:00 2001 From: Nacho Vazquez Date: Sat, 17 Oct 2020 18:50:23 -0300 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20add=20angular-versions-?= =?UTF-8?q?action=20to=20ci=20pipeline=20(#20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 🤖 add angular-verions-action to ci pipeline - this change should allow to test the lib source code with different angular verions * chore: 🤖 add version to angular-versions-action * chore: 🤖 fix angular-versions-action input name * chore: 🤖 use headless test on ci * chore: 🤖 improve compatibility with v9 * chore: 🤖 remove multi version build to check breaking change * chore: 🤖 retry with multiple angular versions * chore: 🤖 fix typo in ci * chore: 🤖 space ci steps * chore: 🤖 use right version of angular-versions-action * chore: 🤖 use latest angular-versions-action * chore: 🤖 use fixed version of angular-versions-action * chore: 🤖 trying with version 8 of Angular * chore: 🤖 modify source code to support angular 8.1 * chore: 🤖 update to use angular-versions-action that support 8.1 * test: add TestBed.inject/TestBed.get wrapper * chore: add format script * style: format * docs: ✏️ add compatibility section in docs * chore: 🤖 migrate to angular-versions-action v2 * fix: 🐛 increase accuracy on lumberjack dependencies range * fix: 🐛 use latest patch version for lumberjack deps range * docs: update compatibility table to express variable patch version Co-authored-by: Lars Gyrup Brink Nielsen Co-authored-by: Nacho Vazquez Co-authored-by: Lars Gyrup Brink Nielsen --- .github/workflows/ci.yml | 9 +- CHANGELOG.md | 24 +- CODE_OF_CONDUCT.md | 20 +- CONTRIBUTING.md | 6 +- README.md | 14 +- angular.json | 5 - e2e/tsconfig.json | 6 +- karma.conf.js | 8 +- package.json | 3 +- projects/ngworker/lumberjack/README.md | 3 +- .../src/console-driver.module.spec.ts | 4 +- .../lumberjack/http-driver/package.json | 4 +- .../src/http-driver-root.module.spec.ts | 3 +- .../src/http-driver.module.spec.ts | 5 +- projects/ngworker/lumberjack/package.json | 2 +- .../src/lib/lumberjack.module.spec.ts | 8 +- .../lib/lumberjack.service.isolated.spec.ts | 4 +- .../lumberjack/src/lib/lumberjack.service.ts | 2 +- .../tests/expect-ng-module-to-be-guarded.ts | 4 +- projects/ngworker/lumberjack/tests/index.ts | 1 + .../lumberjack/tests/resolve-dependency.ts | 18 + src/app/app.component.html | 466 ++++++++++++++---- src/app/app.component.spec.ts | 3 +- src/environments/environment.prod.ts | 2 +- tsconfig.base.json | 2 +- 25 files changed, 465 insertions(+), 161 deletions(-) create mode 100644 projects/ngworker/lumberjack/tests/resolve-dependency.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b6b695b1..e465c6b8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: strategy: matrix: node-version: [10.x, 12.x, 14.x] + angular-version: [8.1.x, 9.0.x, 10.0.x] steps: - uses: actions/checkout@v2 @@ -23,9 +24,15 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} + + - name: Use Angular version ${{ matrix.angular-version }} + uses: ngworker/angular-versions-action@v2 + with: + angular_version: ${{ matrix.angular-version }} + - run: yarn - run: yarn lint - run: yarn build - run: yarn test:headless - run: yarn build:lib - - run: yarn test:lib + - run: yarn test:lib:headless diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dcbd96f0..07418081d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,9 @@ All notable changes to this project will be documented in this file. See [standa ### [1.0.7](https://github.com/ngworker/lumberjack/compare/v1.0.6...v1.0.7) (2020-08-28) - ### Tests -* 💍 add `LumberjackService` base tests ([9b6f961](https://github.com/ngworker/lumberjack/commit/9b6f961c881a15b4dfa92ace308fbd2cb3306aeb)) +- 💍 add `LumberjackService` base tests ([9b6f961](https://github.com/ngworker/lumberjack/commit/9b6f961c881a15b4dfa92ace308fbd2cb3306aeb)) ### [1.0.6](https://github.com/ngworker/lumberjack/compare/v1.0.5...v1.0.6) (2020-07-30) @@ -19,39 +18,34 @@ All notable changes to this project will be documented in this file. See [standa ### [1.0.3](https://github.com/ngworker/lumberjack/compare/v1.0.2...v1.0.3) (2020-07-22) - ### Bug Fixes -* 🐛 remove not published message from readme ([2ccc687](https://github.com/ngworker/lumberjack/commit/2ccc687637894e6f51c2fcfc6fc67d040010ac7a)) +- 🐛 remove not published message from readme ([2ccc687](https://github.com/ngworker/lumberjack/commit/2ccc687637894e6f51c2fcfc6fc67d040010ac7a)) ### [1.0.2](https://github.com/ngworker/lumberjack/compare/v1.0.1...v1.0.2) (2020-07-22) - ### Bug Fixes -* 🐛 cp readme to dist on build lib ([7f04fcc](https://github.com/ngworker/lumberjack/commit/7f04fcc34ad1fe01231182f848e2fbe7dda23cf8)) +- 🐛 cp readme to dist on build lib ([7f04fcc](https://github.com/ngworker/lumberjack/commit/7f04fcc34ad1fe01231182f848e2fbe7dda23cf8)) ### [1.0.1](https://github.com/ngworker/lumberjack/compare/v1.0.0...v1.0.1) (2020-07-22) - ### Bug Fixes -* 🐛 readme and publish info ([#4](https://github.com/ngworker/lumberjack/issues/4)) ([0f63fe9](https://github.com/ngworker/lumberjack/commit/0f63fe9b6acb3d1295d45ef7b3d98ae8ef709224)) +- 🐛 readme and publish info ([#4](https://github.com/ngworker/lumberjack/issues/4)) ([0f63fe9](https://github.com/ngworker/lumberjack/commit/0f63fe9b6acb3d1295d45ef7b3d98ae8ef709224)) ## 1.0.0 (2020-07-22) - ### ⚠ BREAKING CHANGES -* add lumberjack core +- add lumberjack core ### Features -* 🎸 add usage example to app.component ([#2](https://github.com/ngworker/lumberjack/issues/2)) ([637c278](https://github.com/ngworker/lumberjack/commit/637c2780905bfe28fbf6b2e8a11b6204c96f81a1)) -* 🎸 create general structure of lumberjack library ([087b716](https://github.com/ngworker/lumberjack/commit/087b716c0dd40d49490911c2eb5c5ba598918d85)) - +- 🎸 add usage example to app.component ([#2](https://github.com/ngworker/lumberjack/issues/2)) ([637c278](https://github.com/ngworker/lumberjack/commit/637c2780905bfe28fbf6b2e8a11b6204c96f81a1)) +- 🎸 create general structure of lumberjack library ([087b716](https://github.com/ngworker/lumberjack/commit/087b716c0dd40d49490911c2eb5c5ba598918d85)) ### Tests -* 💍 add empty test file ([7f605a2](https://github.com/ngworker/lumberjack/commit/7f605a2515cc173d9d7d6aca804c46cea62bc6bf)) -* 💍 convert app test to spectator and add enhance linting ([#3](https://github.com/ngworker/lumberjack/issues/3)) ([1969806](https://github.com/ngworker/lumberjack/commit/1969806c18eab904a8de85ce512e4f20384a7f6a)) +- 💍 add empty test file ([7f605a2](https://github.com/ngworker/lumberjack/commit/7f605a2515cc173d9d7d6aca804c46cea62bc6bf)) +- 💍 convert app test to spectator and add enhance linting ([#3](https://github.com/ngworker/lumberjack/issues/3)) ([1969806](https://github.com/ngworker/lumberjack/commit/1969806c18eab904a8de85ce512e4f20384a7f6a)) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index c3b924d8e..b91a93816 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5159fa00e..7a8f29ac7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,20 +7,20 @@ Start by installing all dependencies: ```bash -npm i +yarn ``` Run the tests: ```bash -npm test +yarn test yarn e2e ``` Run the playground app: ```bash -npm start +yarn start ``` ## Building diff --git a/README.md b/README.md index dd90d697b..7aa3541e9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [![commitizen](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)]() [![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)]() [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) -[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-) [![ngworker](https://img.shields.io/badge/ngworker-%40-red)](https://github.com/ngworker/) [![spectator](https://img.shields.io/badge/tested%20with-spectator-2196F3.svg?style=flat-square)]() @@ -43,6 +43,18 @@ Lumberjack is a versatile Angular Logging library, specially defined to be exten `yarn add @ngworker/lumberjack` +## Compatibility + +`Lumberjack` has tested compatibility with the following Angular versions. + +> If the version you are using is not listed, please rise an issue. This list only covers tested versions. + +| Angular | Support | +| -------------- | -------- | +| > 10.0.x | ✅ | +| > 9.0.x | ✅ | +| > 8.1.x | ✅ | + ## Usage To start using this app just import it in your application root module. diff --git a/angular.json b/angular.json index 1ae822006..f005b2003 100644 --- a/angular.json +++ b/angular.json @@ -48,11 +48,6 @@ "type": "initial", "maximumWarning": "2mb", "maximumError": "5mb" - }, - { - "type": "anyComponentStyle", - "maximumWarning": "6kb", - "maximumError": "10kb" } ] } diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json index 1807fd68a..612ad2f7c 100644 --- a/e2e/tsconfig.json +++ b/e2e/tsconfig.json @@ -5,10 +5,6 @@ "outDir": "../out-tsc/e2e", "module": "commonjs", "target": "es2018", - "types": [ - "jasmine", - "jasminewd2", - "node" - ] + "types": ["jasmine", "jasminewd2", "node"] } } diff --git a/karma.conf.js b/karma.conf.js index 5073728f6..4895329dd 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,15 +10,15 @@ module.exports = function (config) { require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'), - require('@angular-devkit/build-angular/plugins/karma') + require('@angular-devkit/build-angular/plugins/karma'), ], client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser + clearContext: false, // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { dir: require('path').join(__dirname, './coverage/lumberjack'), reports: ['html', 'lcovonly', 'text-summary'], - fixWebpackSourcePaths: true + fixWebpackSourcePaths: true, }, reporters: ['progress', 'kjhtml'], port: 9876, @@ -27,6 +27,6 @@ module.exports = function (config) { autoWatch: true, browsers: ['Chrome'], singleRun: false, - restartOnFileChange: true + restartOnFileChange: true, }); }; diff --git a/package.json b/package.json index 222c5cf7b..ee6b7c98b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "release": "cd projects/ngworker/lumberjack && standard-version --infile ../../../CHANGELOG.md", "test:lib:headless": "cross-env CI=true yarn test:lib", "publish": "cd dist/ngworker/lumberjack && npm publish", - "ci": "yarn install && yarn lint && yarn build && yarn test:headless && yarn build:lib && yarn test:lib:headless" + "ci": "yarn install && yarn lint && yarn build && yarn test:headless && yarn build:lib && yarn test:lib:headless", + "format": "npx prettier --config prettier.config.js --write \"**/*.*\" \"!dist/**\" \"!yarn.lock\"" }, "private": true, "dependencies": { diff --git a/projects/ngworker/lumberjack/README.md b/projects/ngworker/lumberjack/README.md index 8d0f79edc..557844d8a 100644 --- a/projects/ngworker/lumberjack/README.md +++ b/projects/ngworker/lumberjack/README.md @@ -5,7 +5,8 @@ This library was generated with [Angular CLI](https://github.com/angular/angular ## Code scaffolding Run `ng generate component component-name --project lumberjack` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project lumberjack`. -> Note: Don't forget to add `--project lumberjack` or else it will be added to the default project in your `angular.json` file. + +> Note: Don't forget to add `--project lumberjack` or else it will be added to the default project in your `angular.json` file. ## Build diff --git a/projects/ngworker/lumberjack/console-driver/src/console-driver.module.spec.ts b/projects/ngworker/lumberjack/console-driver/src/console-driver.module.spec.ts index 06d1ce9c2..6f5fbcdc5 100644 --- a/projects/ngworker/lumberjack/console-driver/src/console-driver.module.spec.ts +++ b/projects/ngworker/lumberjack/console-driver/src/console-driver.module.spec.ts @@ -9,7 +9,7 @@ import { LumberjackModule, } from '@ngworker/lumberjack'; -import { expectNgModuleToBeGuarded } from '../../tests/expect-ng-module-to-be-guarded'; +import { expectNgModuleToBeGuarded, resolveDependency } from '../../tests'; import { ConsoleDriverModule } from './console-driver.module'; import { ConsoleDriver } from './console.driver'; @@ -29,7 +29,7 @@ const createConsoleDriver = ({ ], }); - const [consoleDriver] = (TestBed.inject(LogDriverToken) as unknown) as LogDriver[]; + const [consoleDriver] = (resolveDependency(LogDriverToken) as unknown) as LogDriver[]; return consoleDriver; }; diff --git a/projects/ngworker/lumberjack/http-driver/package.json b/projects/ngworker/lumberjack/http-driver/package.json index 56ccc91d6..be58c6ca4 100644 --- a/projects/ngworker/lumberjack/http-driver/package.json +++ b/projects/ngworker/lumberjack/http-driver/package.json @@ -7,8 +7,8 @@ } }, "peerDependencies": { - "@angular/common": "^10.0.14", - "@angular/core": "^10.0.14", + "@angular/common": ">=8.1.3", + "@angular/core": ">=8.1.3", "rxjs": "^6.5.5" } } diff --git a/projects/ngworker/lumberjack/http-driver/src/http-driver-root.module.spec.ts b/projects/ngworker/lumberjack/http-driver/src/http-driver-root.module.spec.ts index d78d168e7..4a43248db 100644 --- a/projects/ngworker/lumberjack/http-driver/src/http-driver-root.module.spec.ts +++ b/projects/ngworker/lumberjack/http-driver/src/http-driver-root.module.spec.ts @@ -11,7 +11,6 @@ describe(HttpDriverRootModule.name, () => { // tslint:disable-next-line: no-null-keyword const optionalAngularDependency = null; - // @ts-expect-error - expect(() => new HttpDriverRootModule(optionalAngularDependency)).not.toThrow(); + expect(() => new HttpDriverRootModule(optionalAngularDependency as any)).not.toThrow(); }); }); diff --git a/projects/ngworker/lumberjack/http-driver/src/http-driver.module.spec.ts b/projects/ngworker/lumberjack/http-driver/src/http-driver.module.spec.ts index def43dece..9ba140f0a 100644 --- a/projects/ngworker/lumberjack/http-driver/src/http-driver.module.spec.ts +++ b/projects/ngworker/lumberjack/http-driver/src/http-driver.module.spec.ts @@ -1,4 +1,3 @@ -import { HttpClientModule } from '@angular/common/http'; import { TestBed } from '@angular/core/testing'; import { @@ -9,7 +8,7 @@ import { LumberjackModule, } from '@ngworker/lumberjack'; -import { expectNgModuleToBeGuarded } from '../../tests/expect-ng-module-to-be-guarded'; +import { expectNgModuleToBeGuarded, resolveDependency } from '../../tests'; import { HttpDriverConfig } from './http-driver.config'; import { HttpDriverModule } from './http-driver.module'; @@ -32,7 +31,7 @@ const createHttpDriver = ( ], }); - const [httpDriver] = (TestBed.inject(LogDriverToken) as unknown) as LogDriver[]; + const [httpDriver] = (resolveDependency(LogDriverToken) as unknown) as LogDriver[]; return httpDriver; }; diff --git a/projects/ngworker/lumberjack/package.json b/projects/ngworker/lumberjack/package.json index 209b82c23..b7c51ab4f 100644 --- a/projects/ngworker/lumberjack/package.json +++ b/projects/ngworker/lumberjack/package.json @@ -2,7 +2,7 @@ "name": "@ngworker/lumberjack", "version": "1.0.8", "peerDependencies": { - "@angular/core": "^10.0.14" + "@angular/core": ">=8.1.3" }, "dependencies": { "tslib": "^2.0.0" diff --git a/projects/ngworker/lumberjack/src/lib/lumberjack.module.spec.ts b/projects/ngworker/lumberjack/src/lib/lumberjack.module.spec.ts index 9df3a4879..b4ebf0d8c 100644 --- a/projects/ngworker/lumberjack/src/lib/lumberjack.module.spec.ts +++ b/projects/ngworker/lumberjack/src/lib/lumberjack.module.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; -import { expectNgModuleToBeGuarded } from '../../tests/expect-ng-module-to-be-guarded'; +import { expectNgModuleToBeGuarded, resolveDependency } from '../../tests'; import { defaultLogConfig, @@ -26,7 +26,7 @@ describe(LumberjackModule.name, () => { imports: [LumberjackModule.forRoot(expectedConfig)], }); - const actualConfig = TestBed.inject(LumberjackLogConfigToken); + const actualConfig = resolveDependency(LumberjackLogConfigToken); expect(actualConfig).toEqual(expectedConfig); }); @@ -35,7 +35,7 @@ describe(LumberjackModule.name, () => { imports: [LumberjackModule.forRoot()], }); - const actualConfig = TestBed.inject(LumberjackLogConfigToken); + const actualConfig = resolveDependency(LumberjackLogConfigToken); expect(actualConfig).toEqual(defaultLogConfig); }); @@ -44,7 +44,7 @@ describe(LumberjackModule.name, () => { imports: [LumberjackModule.forRoot()], }); - const actualConfig = TestBed.inject(LogDriverConfigToken); + const actualConfig = resolveDependency(LogDriverConfigToken); expect(actualConfig).toEqual(defaultLogDriverConfig); }); }); diff --git a/projects/ngworker/lumberjack/src/lib/lumberjack.service.isolated.spec.ts b/projects/ngworker/lumberjack/src/lib/lumberjack.service.isolated.spec.ts index 136f8e940..ff8000f18 100644 --- a/projects/ngworker/lumberjack/src/lib/lumberjack.service.isolated.spec.ts +++ b/projects/ngworker/lumberjack/src/lib/lumberjack.service.isolated.spec.ts @@ -1,5 +1,7 @@ import { TestBed } from '@angular/core/testing'; +import { resolveDependency } from '../../tests'; + import { LogDriverConfig, LogDriverConfigToken } from './configs'; import { createDebugLog } from './log-types'; import { LumberjackModule } from './lumberjack.module'; @@ -9,7 +11,7 @@ const allLogLevelsDisabled: LogDriverConfig = { levels: [], }; const createEmptyDebugLog = createDebugLog(''); -const logEmptyDebugMessage = () => TestBed.inject(LumberjackService).log(createEmptyDebugLog()); +const logEmptyDebugMessage = () => resolveDependency(LumberjackService).log(createEmptyDebugLog()); describe(LumberjackService.name, () => { it('accepts logs when no log drivers are registered', () => { diff --git a/projects/ngworker/lumberjack/src/lib/lumberjack.service.ts b/projects/ngworker/lumberjack/src/lib/lumberjack.service.ts index 79d3237d8..8c75fe780 100644 --- a/projects/ngworker/lumberjack/src/lib/lumberjack.service.ts +++ b/projects/ngworker/lumberjack/src/lib/lumberjack.service.ts @@ -23,7 +23,7 @@ export class LumberjackService { // and use it to log to its output. @Optional() @Inject(LogDriverToken) logDrivers?: LogDriver[] ) { - logDrivers = logDrivers ?? []; + logDrivers = logDrivers || []; this.logDrivers = Array.isArray(logDrivers) ? logDrivers : [logDrivers]; } diff --git a/projects/ngworker/lumberjack/tests/expect-ng-module-to-be-guarded.ts b/projects/ngworker/lumberjack/tests/expect-ng-module-to-be-guarded.ts index 484113f9c..e1e7e105b 100644 --- a/projects/ngworker/lumberjack/tests/expect-ng-module-to-be-guarded.ts +++ b/projects/ngworker/lumberjack/tests/expect-ng-module-to-be-guarded.ts @@ -1,6 +1,8 @@ import { Type } from '@angular/core'; import { TestBed } from '@angular/core/testing'; +import { resolveDependency } from './resolve-dependency'; + export const expectNgModuleToBeGuarded = (ngModuleType: Type) => { let ngModule: TModule | undefined; @@ -9,7 +11,7 @@ export const expectNgModuleToBeGuarded = (ngModuleType: Type) }); expect(() => { - ngModule = TestBed.inject(ngModuleType); + ngModule = resolveDependency(ngModuleType); }) .withContext(`${ngModuleType.name} must guard against being imported directly`) .toThrow(); diff --git a/projects/ngworker/lumberjack/tests/index.ts b/projects/ngworker/lumberjack/tests/index.ts index fad44956d..6ad6d33f8 100644 --- a/projects/ngworker/lumberjack/tests/index.ts +++ b/projects/ngworker/lumberjack/tests/index.ts @@ -1 +1,2 @@ export * from './expect-ng-module-to-be-guarded'; +export * from './resolve-dependency'; diff --git a/projects/ngworker/lumberjack/tests/resolve-dependency.ts b/projects/ngworker/lumberjack/tests/resolve-dependency.ts new file mode 100644 index 000000000..ba935bd9c --- /dev/null +++ b/projects/ngworker/lumberjack/tests/resolve-dependency.ts @@ -0,0 +1,18 @@ +import { AbstractType, InjectFlags, InjectionToken, Type } from '@angular/core'; +import { TestBed } from '@angular/core/testing'; + +const inject: Function = (TestBed as any).inject || (TestBed as any).get; + +export function resolveDependency( + token: Type | InjectionToken | AbstractType, + notFoundValue?: T, + flags?: InjectFlags +): T; +export function resolveDependency( + token: Type | InjectionToken | AbstractType, + // tslint:disable-next-line: no-null-keyword + notFoundValue: null, + flags?: InjectFlags +): T | null { + return inject(token, notFoundValue, flags); +} diff --git a/src/app/app.component.html b/src/app/app.component.html index fdb26fbd7..886a39dcc 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -9,7 +9,8 @@