diff --git a/package-lock.json b/package-lock.json index 6195ce174..0998d1cda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14796,9 +14796,9 @@ "dev": true }, "typescript": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz", - "integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz", + "integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==", "dev": true }, "uglify-js": { diff --git a/package.json b/package.json index 26b4ad669..0384c4eb0 100644 --- a/package.json +++ b/package.json @@ -15,23 +15,13 @@ "publish": "npm run build && npm publish ./dist/common" }, "description": "A set of common utils for consuming Web APIs with Angular", - "keywords": [ - "angular", - "ng", - "window", - "api", - "web api", - "navigator", - "user agent" - ], + "keywords": ["angular", "ng", "window", "api", "web api", "navigator", "user agent"], "license": "MIT", "author": { "name": "Alex Inkin", "email": "alexander@inkin.ru" }, - "contributors": [ - "Roman Sedov <79601794011@ya.ru> (http://marsibarsi.me/)" - ], + "contributors": ["Roman Sedov <79601794011@ya.ru> (http://marsibarsi.me/)"], "repository": "https://github.com/ng-web-apis/common", "bugs": "https://github.com/ng-web-apis/common/issues", "homepage": "https://github.com/ng-web-apis/common#README", @@ -92,7 +82,7 @@ "tsickle": "0.34.0", "tslint": "^5.18.0", "tsutils": "^3.17.1", - "typescript": "3.1.6" + "typescript": "3.2.2" }, "husky": { "hooks": { @@ -100,10 +90,7 @@ } }, "lint-staged": { - "*.{js,ts,html,md,less,json}": [ - "prettier --write", - "git add" - ], + "*.{js,ts,html,md,less,json}": ["prettier --write", "git add"], "*.ts": "tslint" }, "standard-version": { diff --git a/projects/common/src/tokens/css.ts b/projects/common/src/tokens/css.ts index f10ec77c2..0e95a2ccb 100644 --- a/projects/common/src/tokens/css.ts +++ b/projects/common/src/tokens/css.ts @@ -1,15 +1,18 @@ import {inject, InjectionToken} from '@angular/core'; import {WINDOW} from './window'; -declare global { - interface Window { - CSS: CSS; - } +/** + * Use Window['CSS'], this is a workaround to support Angular 6+ + */ +interface Css { + escape(ident: string): string; + supports(property: string, value: string): boolean; + supports(conditionText: string): boolean; } -export const CSS = new InjectionToken('An abstraction over window.CSS object', { +export const CSS = new InjectionToken('An abstraction over window.CSS object', { factory: () => - inject(WINDOW).CSS || { + (inject(WINDOW) as any).CSS || { escape: v => v, supports: () => false, }, diff --git a/projects/common/src/tokens/tests/css.spec.ts b/projects/common/src/tokens/tests/css.spec.ts index ec4b60e0f..111560f55 100644 --- a/projects/common/src/tokens/tests/css.spec.ts +++ b/projects/common/src/tokens/tests/css.spec.ts @@ -6,6 +6,7 @@ describe('CSS', () => { it('injects window.CSS object', () => { TestBed.configureTestingModule({}); + // @ts-ignore expect(TestBed.get(CSS)).toBe(window.CSS); });