From 328511be8e55e8366edf64f64d5332e11b3ba78a Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 20 Mar 2018 00:01:31 -0700 Subject: [PATCH] build(aio): update to typescript@2.7.2 (#22872) PR Close #22872 --- aio/package.json | 2 +- aio/src/app/app.module.spec.ts | 0 .../custom-elements/api/api.service.spec.ts | 7 +++++-- .../custom-elements/elements-loader.spec.ts | 2 -- .../resource/resource-list.component.spec.ts | 2 -- .../file-not-found-search.component.spec.ts | 2 -- .../app/documents/document.service.spec.ts | 20 +++++++++---------- .../notification.component.spec.ts | 2 -- aio/src/app/layout/toc/toc.component.spec.ts | 2 -- aio/src/app/shared/logger.service.spec.ts | 4 ++-- .../shared/select/select.component.spec.ts | 2 -- aio/tsconfig.json | 4 ++++ aio/yarn.lock | 6 +----- 13 files changed, 23 insertions(+), 32 deletions(-) delete mode 100644 aio/src/app/app.module.spec.ts diff --git a/aio/package.json b/aio/package.json index 7c5cc21c22..038b53e009 100644 --- a/aio/package.json +++ b/aio/package.json @@ -146,7 +146,7 @@ "tree-kill": "^1.1.0", "ts-node": "^3.3.0", "tslint": "~4.5.0", - "typescript": "^2.5.3", + "typescript": "^2.7.2", "uglify-js": "^3.0.15", "unist-util-filter": "^0.2.1", "unist-util-source": "^1.0.1", diff --git a/aio/src/app/app.module.spec.ts b/aio/src/app/app.module.spec.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/aio/src/app/custom-elements/api/api.service.spec.ts b/aio/src/app/custom-elements/api/api.service.spec.ts index 709fd67923..f236cdde23 100644 --- a/aio/src/app/custom-elements/api/api.service.spec.ts +++ b/aio/src/app/custom-elements/api/api.service.spec.ts @@ -49,17 +49,18 @@ describe('ApiService', () => { describe('#sections', () => { - it('first subscriber should fetch sections', () => { + it('first subscriber should fetch sections', done => { const data = [{name: 'a', title: 'A', items: []}, {name: 'b', title: 'B', items: []}]; service.sections.subscribe(sections => { expect(sections).toEqual(data); + done(); }); httpMock.expectOne({}).flush(data); }); - it('second subscriber should get previous sections and NOT trigger refetch', () => { + it('second subscriber should get previous sections and NOT trigger refetch', done => { const data = [{name: 'a', title: 'A', items: []}, {name: 'b', title: 'B', items: []}]; let subscriptions = 0; @@ -71,6 +72,8 @@ describe('ApiService', () => { service.sections.subscribe(sections => { subscriptions++; expect(sections).toEqual(data); + expect(subscriptions).toBe(2); + done(); }); httpMock.expectOne({}).flush(data); diff --git a/aio/src/app/custom-elements/elements-loader.spec.ts b/aio/src/app/custom-elements/elements-loader.spec.ts index 3d9ac80fed..1fc4eed22c 100644 --- a/aio/src/app/custom-elements/elements-loader.spec.ts +++ b/aio/src/app/custom-elements/elements-loader.spec.ts @@ -33,7 +33,6 @@ const FAKE_COMPONENT_FACTORIES = new Map([ describe('ElementsLoader', () => { let elementsLoader: ElementsLoader; - let injectedModuleRef: NgModuleRef; let actualCustomElementsDefine; let fakeCustomElementsDefine; @@ -61,7 +60,6 @@ describe('ElementsLoader', () => { ] }); - injectedModuleRef = injector.get(NgModuleRef); elementsLoader = injector.get(ElementsLoader); }); diff --git a/aio/src/app/custom-elements/resource/resource-list.component.spec.ts b/aio/src/app/custom-elements/resource/resource-list.component.spec.ts index 5042bf2c20..ecbee8f02c 100644 --- a/aio/src/app/custom-elements/resource/resource-list.component.spec.ts +++ b/aio/src/app/custom-elements/resource/resource-list.component.spec.ts @@ -14,7 +14,6 @@ describe('ResourceListComponent', () => { let injector: ReflectiveInjector; let location: TestPlatformLocation; - let resourceService: TestResourceService; beforeEach(() => { injector = ReflectiveInjector.resolveAndCreate([ @@ -24,7 +23,6 @@ describe('ResourceListComponent', () => { ]); location = injector.get(PlatformLocation); - resourceService = injector.get(ResourceService); }); it('should set the location w/o leading slashes', () => { diff --git a/aio/src/app/custom-elements/search/file-not-found-search.component.spec.ts b/aio/src/app/custom-elements/search/file-not-found-search.component.spec.ts index 175832ef32..f1a903b811 100644 --- a/aio/src/app/custom-elements/search/file-not-found-search.component.spec.ts +++ b/aio/src/app/custom-elements/search/file-not-found-search.component.spec.ts @@ -10,7 +10,6 @@ import { FileNotFoundSearchComponent } from './file-not-found-search.component'; describe('FileNotFoundSearchComponent', () => { - let element: HTMLElement; let fixture: ComponentFixture; let searchService: SearchService; let searchResultSubject: Subject; @@ -30,7 +29,6 @@ describe('FileNotFoundSearchComponent', () => { searchResultSubject = new Subject(); spyOn(searchService, 'search').and.callFake(() => searchResultSubject.asObservable()); fixture.detectChanges(); - element = fixture.nativeElement; }); it('should run a search with a query built from the current url', () => { diff --git a/aio/src/app/documents/document.service.spec.ts b/aio/src/app/documents/document.service.spec.ts index f4af31aa4a..3fb484cfc8 100644 --- a/aio/src/app/documents/document.service.spec.ts +++ b/aio/src/app/documents/document.service.spec.ts @@ -104,15 +104,15 @@ describe('DocumentService', () => { }); it('should use a hard-coded error doc if the request fails (but not cache it)', () => { - let latestDocument: DocumentContents|undefined; - const doc1 = { contents: 'doc 1' }; - const doc2 = { contents: 'doc 2' }; + let latestDocument!: DocumentContents; + const doc1 = { contents: 'doc 1' } as DocumentContents; + const doc2 = { contents: 'doc 2' } as DocumentContents; const { docService, locationService, logger } = getServices('initial/doc'); docService.currentDocument.subscribe(doc => latestDocument = doc); httpMock.expectOne({}).flush(null, {status: 500, statusText: 'Server Error'}); - expect(latestDocument!.id).toEqual(FETCHING_ERROR_ID); + expect(latestDocument.id).toEqual(FETCHING_ERROR_ID); expect(logger.output.error).toEqual([ [jasmine.any(Error)] ]); @@ -129,14 +129,14 @@ describe('DocumentService', () => { }); it('should not crash the app if the response is invalid JSON', () => { - let latestDocument: DocumentContents|undefined; - const doc1 = { contents: 'doc 1' }; + let latestDocument!: DocumentContents; + const doc1 = { contents: 'doc 1' } as DocumentContents; const { docService, locationService } = getServices('initial/doc'); docService.currentDocument.subscribe(doc => latestDocument = doc); httpMock.expectOne({}).flush('this is invalid JSON'); - expect(latestDocument!.id).toEqual(FETCHING_ERROR_ID); + expect(latestDocument.id).toEqual(FETCHING_ERROR_ID); locationService.go('new/doc'); httpMock.expectOne({}).flush(doc1); @@ -144,11 +144,11 @@ describe('DocumentService', () => { }); it('should not make a request to the server if the doc is in the cache already', () => { - let latestDocument: DocumentContents|undefined; + let latestDocument!: DocumentContents; let subscription: Subscription; - const doc0 = { contents: 'doc 0' }; - const doc1 = { contents: 'doc 1' }; + const doc0 = { contents: 'doc 0' } as DocumentContents; + const doc1 = { contents: 'doc 1' } as DocumentContents; const { docService, locationService } = getServices('url/0'); subscription = docService.currentDocument.subscribe(doc => latestDocument = doc); diff --git a/aio/src/app/layout/notification/notification.component.spec.ts b/aio/src/app/layout/notification/notification.component.spec.ts index f54335e8a7..be4499679a 100644 --- a/aio/src/app/layout/notification/notification.component.spec.ts +++ b/aio/src/app/layout/notification/notification.component.spec.ts @@ -7,7 +7,6 @@ import { NotificationComponent } from './notification.component'; import { WindowToken } from 'app/shared/window'; describe('NotificationComponent', () => { - let element: HTMLElement; let component: NotificationComponent; let fixture: ComponentFixture; @@ -26,7 +25,6 @@ describe('NotificationComponent', () => { function createComponent() { fixture = TestBed.createComponent(TestComponent); const debugElement = fixture.debugElement.query(By.directive(NotificationComponent)); - element = debugElement.nativeElement; component = debugElement.componentInstance; component.ngOnInit(); fixture.detectChanges(); diff --git a/aio/src/app/layout/toc/toc.component.spec.ts b/aio/src/app/layout/toc/toc.component.spec.ts index d4285d4452..c736177729 100644 --- a/aio/src/app/layout/toc/toc.component.spec.ts +++ b/aio/src/app/layout/toc/toc.component.spec.ts @@ -246,12 +246,10 @@ describe('TocComponent', () => { describe('when in side panel (not embedded)', () => { let fixture: ComponentFixture; - let scrollToTopSpy: jasmine.Spy; beforeEach(() => { fixture = TestBed.createComponent(HostNotEmbeddedTocComponent); - scrollToTopSpy = TestBed.get(ScrollService).scrollToTop; tocComponentDe = fixture.debugElement.children[0]; tocComponent = tocComponentDe.componentInstance; tocService = TestBed.get(TocService); diff --git a/aio/src/app/shared/logger.service.spec.ts b/aio/src/app/shared/logger.service.spec.ts index a197cdf643..d676cc4e37 100644 --- a/aio/src/app/shared/logger.service.spec.ts +++ b/aio/src/app/shared/logger.service.spec.ts @@ -21,14 +21,14 @@ describe('logger service', () => { describe('log', () => { it('should delegate to console.log', () => { logger.log('param1', 'param2', 'param3'); - expect(console.log).toHaveBeenCalledWith('param1', 'param2', 'param3'); + expect(logSpy).toHaveBeenCalledWith('param1', 'param2', 'param3'); }); }); describe('warn', () => { it('should delegate to console.warn', () => { logger.warn('param1', 'param2', 'param3'); - expect(console.warn).toHaveBeenCalledWith('param1', 'param2', 'param3'); + expect(warnSpy).toHaveBeenCalledWith('param1', 'param2', 'param3'); }); }); diff --git a/aio/src/app/shared/select/select.component.spec.ts b/aio/src/app/shared/select/select.component.spec.ts index c21b55dd65..d175e613d3 100644 --- a/aio/src/app/shared/select/select.component.spec.ts +++ b/aio/src/app/shared/select/select.component.spec.ts @@ -8,7 +8,6 @@ const options = [ { title: 'Option B', value: 'option-b' } ]; -let component: SelectComponent; let host: HostComponent; let fixture: ComponentFixture; let element: DebugElement; @@ -25,7 +24,6 @@ describe('SelectComponent', () => { fixture = TestBed.createComponent(HostComponent); host = fixture.componentInstance; element = fixture.debugElement.query(By.directive(SelectComponent)); - component = element.componentInstance; }); describe('(initially)', () => { diff --git a/aio/tsconfig.json b/aio/tsconfig.json index 64194c0cc1..3ad01dc727 100644 --- a/aio/tsconfig.json +++ b/aio/tsconfig.json @@ -3,6 +3,10 @@ "compilerOptions": { "strict": true, "noImplicitAny": false, + // disabled because this is on by default in tsc 2.7 breaking our codebase - we need to refactor + "strictPropertyInitialization": false, + // disabled because of https://github.com/angular/angular/issues/22877 + "skipLibCheck": true, "outDir": "./dist/out-tsc", "baseUrl": "src", "sourceMap": true, diff --git a/aio/yarn.lock b/aio/yarn.lock index 8486ba7db4..1f2c3db72a 100644 --- a/aio/yarn.lock +++ b/aio/yarn.lock @@ -8805,11 +8805,7 @@ typescript@^2.4.1, typescript@~2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" -typescript@^2.5.3: - version "2.5.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.3.tgz#df3dcdc38f3beb800d4bc322646b04a3f6ca7f0d" - -typescript@~2.7.1: +typescript@^2.7.2, typescript@~2.7.1: version "2.7.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836"