diff --git a/aio/package.json b/aio/package.json index a77f093f87..05c291185b 100644 --- a/aio/package.json +++ b/aio/package.json @@ -101,6 +101,7 @@ "@types/jasmine": "^2.5.52", "@types/jasminewd2": "^2.0.4", "@types/node": "~6.0.60", + "@types/xregexp": "^3.0.29", "@yarnpkg/lockfile": "^1.1.0", "archiver": "^1.3.0", "canonical-path": "1.0.0", diff --git a/aio/src/app/app.component.spec.ts b/aio/src/app/app.component.spec.ts index def9049713..74b2abd3f3 100644 --- a/aio/src/app/app.component.spec.ts +++ b/aio/src/app/app.component.spec.ts @@ -652,11 +652,11 @@ describe('AppComponent', () => { component.tocMaxHeight = '100'; fixture.detectChanges(); - expect(tocContainer!.style['max-height']).toBe('100px'); + expect(tocContainer!.style.maxHeight).toBe('100px'); component.tocMaxHeight = '200'; fixture.detectChanges(); - expect(tocContainer!.style['max-height']).toBe('200px'); + expect(tocContainer!.style.maxHeight).toBe('200px'); }); it('should restrain scrolling inside the ToC container', () => { diff --git a/aio/src/app/custom-elements/code/code-tabs.component.ts b/aio/src/app/custom-elements/code/code-tabs.component.ts index d2d080dca2..e8a1cbd5a8 100644 --- a/aio/src/app/custom-elements/code/code-tabs.component.ts +++ b/aio/src/app/custom-elements/code/code-tabs.component.ts @@ -1,5 +1,5 @@ /* tslint:disable component-selector */ -import { Component, AfterViewInit, ViewChild, Input, ViewChildren, QueryList, OnInit } from '@angular/core'; +import { AfterViewInit, Component, ElementRef, Input, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core'; import { CodeComponent } from './code.component'; export interface TabInfo { @@ -48,7 +48,7 @@ export class CodeTabsComponent implements OnInit, AfterViewInit { @Input() linenums: string; - @ViewChild('content', { static: true }) content; + @ViewChild('content', { static: true }) content: ElementRef; @ViewChildren(CodeComponent) codeComponents: QueryList; diff --git a/aio/src/app/custom-elements/elements-loader.spec.ts b/aio/src/app/custom-elements/elements-loader.spec.ts index a22304faac..acb2befd82 100644 --- a/aio/src/app/custom-elements/elements-loader.spec.ts +++ b/aio/src/app/custom-elements/elements-loader.spec.ts @@ -249,7 +249,7 @@ class FakeComponentFactory extends ComponentFactory { } class FakeComponentFactoryResolver extends ComponentFactoryResolver { - constructor(private modulePath) { super(); } + constructor(private modulePath: string) { super(); } resolveComponentFactory(component: Type): ComponentFactory { return new FakeComponentFactory(this.modulePath); @@ -261,7 +261,7 @@ class FakeModuleRef extends NgModuleRef { componentFactoryResolver = new FakeComponentFactoryResolver(this.modulePath); instance: WithCustomElementComponent = new FakeCustomElementModule(); - constructor(private modulePath) { + constructor(private modulePath: string) { super(); this.injector.get.and.returnValue(this.componentFactoryResolver); @@ -275,7 +275,7 @@ class FakeModuleFactory extends NgModuleFactory { moduleType: Type; moduleRefToCreate = new FakeModuleRef(this.modulePath); - constructor(private modulePath) { super(); } + constructor(private modulePath: string) { super(); } create(parentInjector: Injector | null): NgModuleRef { return this.moduleRefToCreate; diff --git a/aio/src/app/shared/custom-icon-registry.ts b/aio/src/app/shared/custom-icon-registry.ts index 4ec9aa5e3a..156cf8b038 100644 --- a/aio/src/app/shared/custom-icon-registry.ts +++ b/aio/src/app/shared/custom-icon-registry.ts @@ -41,7 +41,7 @@ const DEFAULT_NS = '$$default'; export class CustomIconRegistry extends MatIconRegistry { private preloadedSvgElements: SvgIconMap = {[DEFAULT_NS]: {}}; - constructor(http: HttpClient, sanitizer: DomSanitizer, @Optional() @Inject(DOCUMENT) document, + constructor(http: HttpClient, sanitizer: DomSanitizer, @Optional() @Inject(DOCUMENT) document: Document, @Inject(SVG_ICONS) svgIcons: SvgIconInfo[]) { super(http, sanitizer, document); this.loadSvgElements(svgIcons); diff --git a/aio/tests/deployment/e2e/smoke-tests.e2e-spec.ts b/aio/tests/deployment/e2e/smoke-tests.e2e-spec.ts index 2da958f390..fe9e8025c8 100644 --- a/aio/tests/deployment/e2e/smoke-tests.e2e-spec.ts +++ b/aio/tests/deployment/e2e/smoke-tests.e2e-spec.ts @@ -23,7 +23,7 @@ describe(browser.baseUrl, () => { }); describe('(marketing pages)', () => { - const textPerUrl = { + const textPerUrl: { [key: string]: string } = { features: 'features & benefits', docs: 'what is angular?', events: 'events', @@ -41,7 +41,7 @@ describe(browser.baseUrl, () => { }); describe('(docs pages)', () => { - const textPerUrl = { + const textPerUrl: { [key: string]: string } = { api: 'api list', 'guide/architecture': 'architecture', 'guide/http': 'httpclient', @@ -61,7 +61,7 @@ describe(browser.baseUrl, () => { }); describe('(api docs pages)', () => { - const textPerUrl = { + const textPerUrl: { [key: string]: string } = { /* Class */ 'api/core/Injector': 'class injector', /* Const */ 'api/forms/NG_VALIDATORS': 'const ng_validators', /* Decorator */ 'api/core/Component': '@component', diff --git a/aio/tests/deployment/e2e/tsconfig.json b/aio/tests/deployment/e2e/tsconfig.json index 32743ce131..d6c4da3ef6 100644 --- a/aio/tests/deployment/e2e/tsconfig.json +++ b/aio/tests/deployment/e2e/tsconfig.json @@ -4,6 +4,7 @@ "module": "commonjs" }, "include": [ + "../shared/**/*.d.ts", "**/*.ts" ] } diff --git a/aio/tests/deployment/shared/cjson.d.ts b/aio/tests/deployment/shared/cjson.d.ts new file mode 100644 index 0000000000..6c0947030e --- /dev/null +++ b/aio/tests/deployment/shared/cjson.d.ts @@ -0,0 +1,3 @@ +declare module 'cjson' { + const load: (path: string) => { [key: string]: any }; +} diff --git a/aio/tests/deployment/unit/tsconfig.json b/aio/tests/deployment/unit/tsconfig.json index 32743ce131..d6c4da3ef6 100644 --- a/aio/tests/deployment/unit/tsconfig.json +++ b/aio/tests/deployment/unit/tsconfig.json @@ -4,6 +4,7 @@ "module": "commonjs" }, "include": [ + "../shared/**/*.d.ts", "**/*.ts" ] } diff --git a/aio/tests/e2e/src/api.po.ts b/aio/tests/e2e/src/api.po.ts index b2bb4a3b15..28da4561ec 100644 --- a/aio/tests/e2e/src/api.po.ts +++ b/aio/tests/e2e/src/api.po.ts @@ -28,15 +28,15 @@ export class ApiPage extends SitePage { return element.all(by.css(selector)).map(item => item && item.getText()); } - getOverview(docType) { + getOverview(docType: string) { return element(by.css(`.${docType}-overview`)); } - getSection(cls) { + getSection(cls: string) { return element(by.css(`section.${cls}`)); } - getBadge(cls) { + getBadge(cls: string) { return element(by.css('.api-status-label.' + cls)); } } diff --git a/aio/tests/e2e/src/app.po.ts b/aio/tests/e2e/src/app.po.ts index c15b84f35a..76390c1f6a 100644 --- a/aio/tests/e2e/src/app.po.ts +++ b/aio/tests/e2e/src/app.po.ts @@ -33,12 +33,12 @@ export class SitePage { const script = `return arguments[0].parentNode.querySelector('${targetSelector}');`; return element(() => browser.executeScript(script, heading)); } - getTopMenuLink(path) { return element(by.css(`aio-top-menu a[href="${path}"]`)); } + getTopMenuLink(path: string) { return element(by.css(`aio-top-menu a[href="${path}"]`)); } ga() { return browser.executeScript('return window["ga"].q') as promise.Promise; } locationPath() { return browser.executeScript('return document.location.pathname') as promise.Promise; } - navigateTo(pageUrl) { + navigateTo(pageUrl: string) { // Navigate to the page, disable animations, and wait for Angular. return browser.get('/' + pageUrl) .then(() => browser.executeScript('document.body.classList.add(\'no-animations\')')) @@ -49,7 +49,7 @@ export class SitePage { return this.docViewer.getText(); } - getInnerHtml(elementFinder) { + getInnerHtml(elementFinder: ElementFinder) { // `getInnerHtml` was removed from webDriver and this is the workaround. // See https://github.com/angular/protractor/blob/master/CHANGELOG.md#breaking-changes return browser.executeScript('return arguments[0].innerHTML;', elementFinder); diff --git a/aio/tests/e2e/src/onerror.e2e-spec.ts b/aio/tests/e2e/src/onerror.e2e-spec.ts index 733681bea6..3b199a9c89 100644 --- a/aio/tests/e2e/src/onerror.e2e-spec.ts +++ b/aio/tests/e2e/src/onerror.e2e-spec.ts @@ -53,7 +53,7 @@ ZoneDelegate.prototype.invokeTask@https://example.com/packages/zone.js@0.8.18/di forkInnerZoneWithAngularBehavior/zone._inner<.onInvokeTask@https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:4656:24 ZoneDelegate.prototype.invokeTask@https://example.com/packages/zone.js@0.8.18/dist/zone.js:424:17 Zone.prototype.runTask@https://example.com/packages/zone.js@0.8.18/dist/zone.js:192:28 -drainMicroTaskQueue@https://example.com/packages/zone.js@0.8.18/dist/zone.js:602:25` }); +drainMicroTaskQueue@https://example.com/packages/zone.js@0.8.18/dist/zone.js:602:25` } as Error); expect(message).toEqual(`something terrible has happened. oh no. oh no. AppComponent@app.component.ts:31:29 @@ -80,7 +80,7 @@ createDirectiveInstance@core.umd.j`); onInvokeTask runTask drainMicroTaskQueue - promiseReactionJob@[native code]` }); + promiseReactionJob@[native code]` } as Error); expect(message).toEqual(`something terrible has happened. oh no. oh no. AppComponent @@ -104,7 +104,7 @@ cr`); at Object.debugCreateRootView [as createRootView] (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:14079:12) at ComponentFactory_.create (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:10998:46) at ComponentFactoryBoundToModule.create (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:3958:29) - at ApplicationRef.bootstrap (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:5769:57)` }); + at ApplicationRef.bootstrap (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:5769:57)` } as Error); expect(message).toEqual(`something terrible has happened. oh no. oh no. new AppComponent@app.component.ts:31:29 @@ -124,7 +124,7 @@ createDirectiveInstance@core.u`); at Object.debugCreateRootView [as createRootView] (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:14079:12) at ComponentFactory_.create (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:10998:46) at ComponentFactoryBoundToModule.create (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:3958:29) - at ApplicationRef.bootstrap (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:5769:57)` }); + at ApplicationRef.bootstrap (https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:5769:57)` } as Error); expect(message).toEqual(`something terrible has happened. oh no. oh no. new AppComponent@app.component.ts:31:29 @@ -156,7 +156,7 @@ ZoneDelegate.prototype.invokeTask@https://example.com/packages/zone.js@0.8.18/di onInvokeTask@https://example.com/packages/@angular/core@5.0.0/bundles/core.umd.js:4656:24 ZoneDelegate.prototype.invokeTask@https://example.com/packages/zone.js@0.8.18/dist/zone.js:424:17 Zone.prototype.runTask@https://example.com/packages/zone.js@0.8.18/dist/zone.js:192:28 -drainMicroTaskQueue@https://example.com/packages/zone.js@0.8.18/dist/zone.js:602:25` }); +drainMicroTaskQueue@https://example.com/packages/zone.js@0.8.18/dist/zone.js:602:25` } as Error); expect(message).toEqual(`something terrible has happened. oh no. oh no. AppComponent@app.component.ts:31:29 @@ -176,7 +176,7 @@ createDirectiveInstance@core.umd.j`); at debugCreateRootView (eval code:14079:5) at ComponentFactory_.prototype.create (eval code:10998:9) at ComponentFactoryBoundToModule.prototype.create (eval code:3958:9) - at ApplicationRef.prototype.bootstrap (eval code:5769:9)` }); + at ApplicationRef.prototype.bootstrap (eval code:5769:9)` } as Error); expect(message).toEqual(`something terrible has happened. oh no. oh no. AppComponent@???:31:21 @@ -185,7 +185,7 @@ createDirectiveInstance@???:12049:5 createViewNodes@???`); }); - async function callOnError(message, url, line, column, error) { + async function callOnError(message: string, url?: string, line?: number, column?: number, error?: Error) { await browser.executeScript(function() { // reset the ga queue (window as any).ga.q.length = 0; diff --git a/aio/tests/e2e/src/search.e2e-spec.ts b/aio/tests/e2e/src/search.e2e-spec.ts index 12dff497c8..bcd6143eb8 100644 --- a/aio/tests/e2e/src/search.e2e-spec.ts +++ b/aio/tests/e2e/src/search.e2e-spec.ts @@ -1,7 +1,7 @@ import { SitePage } from './app.po'; describe('site search', () => { - let page; + let page: SitePage; beforeEach(() => { page = new SitePage(); diff --git a/aio/tools/firebase-test-utils/FirebaseGlob.ts b/aio/tools/firebase-test-utils/FirebaseGlob.ts index 1e26d668ce..d4378c1a8e 100644 --- a/aio/tools/firebase-test-utils/FirebaseGlob.ts +++ b/aio/tools/firebase-test-utils/FirebaseGlob.ts @@ -1,5 +1,10 @@ import * as XRegExp from 'xregexp'; +// The `XRegExp` typings are not accurate. +interface XRegExp extends RegExp { + xregexp: { captureNames?: string[] }; +} + const dot = /\./g; const star = /\*/g; const doubleStar = /(^|\/)\*\*($|\/)/g; // e.g. a/**/b or **/b or a/** but not a**b @@ -36,7 +41,7 @@ export class FirebaseGlob { .replace(possiblyEmptySegments, '(?:/|/.*/)') // deal with /**/ special cases .replace(willBeStar, '*'); // other ** matches this.pattern = `^${pattern}$`; - this.regex = XRegExp(this.pattern); + this.regex = XRegExp(this.pattern) as XRegExp; } catch (e) { throw new Error(`Error in FirebaseGlob: "${glob}" - ${e.message}`); } @@ -47,17 +52,17 @@ export class FirebaseGlob { } match(url: string) { - const match = XRegExp.exec(url, this.regex); + const match = XRegExp.exec(url, this.regex) as ReturnType & { [captured: string]: string }; if (match) { - const result = {}; - const names = (this.regex as any).xregexp.captureNames || []; - names.forEach(name => result[name] = match[name]); + const result: { [key: string]: string } = {}; + const names = this.regex.xregexp.captureNames || []; + names.forEach(name => result[name] = (match[name])); return result; } } } -function replaceModifiedPattern(_, modifier, pattern) { +function replaceModifiedPattern(_: string, modifier: string, pattern: string) { switch (modifier) { case '!': throw new Error(`"not" expansions are not supported: "${_}"`); diff --git a/aio/tsconfig.json b/aio/tsconfig.json index 29c05e54f8..9c7eaa54ba 100644 --- a/aio/tsconfig.json +++ b/aio/tsconfig.json @@ -20,7 +20,6 @@ ], "skipLibCheck": true, "strict": true, - "noImplicitAny": false, "noUnusedLocals": true, // disabled because this is on by default in tsc 2.7 breaking our codebase - we need to refactor "strictPropertyInitialization": false diff --git a/aio/yarn.lock b/aio/yarn.lock index 1cfc15add4..b69c07e224 100644 --- a/aio/yarn.lock +++ b/aio/yarn.lock @@ -433,6 +433,11 @@ "@types/source-list-map" "*" source-map "^0.6.1" +"@types/xregexp@^3.0.29": + version "3.0.29" + resolved "https://registry.yarnpkg.com/@types/xregexp/-/xregexp-3.0.29.tgz#9f2f819712ab41fd8b434036ec4b14cbb9dbe654" + integrity sha512-mm6iZYQ1xbVBNsWq2VSMFuneRuO0k0wUqIT4ZfrtbD1Eb90DXmqBOPA/URyUHq6wsftxr8aXDJHTTHyyBBY95w== + "@webassemblyjs/ast@1.8.5": version "1.8.5" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359"