From cdfe8f4d69e99673e98e8f3913cbe91bd4ae2af1 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sun, 16 Dec 2018 23:02:48 -0800 Subject: [PATCH] fix(docs-infra): workaround for broken 'import as' (#27536) It's unclear why `import as` results in the aliases to be undefined. Plain tsc seems to do the right thing and emits the correct code, so it might be some kind of interaction in @angular/cli or webpack that are causing the failure. This should be investigated separately from the tsc update in angular/angular. See angular/angular-cli#13212 PR Close #27536 --- aio/src/app/custom-elements/code/pretty-printer.service.ts | 4 ++-- aio/src/app/custom-elements/elements-loader.ts | 5 +++-- aio/src/app/custom-elements/toc/toc.component.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/aio/src/app/custom-elements/code/pretty-printer.service.ts b/aio/src/app/custom-elements/code/pretty-printer.service.ts index d56a3a27fc..63b6fa69b3 100644 --- a/aio/src/app/custom-elements/code/pretty-printer.service.ts +++ b/aio/src/app/custom-elements/code/pretty-printer.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -import { from as fromPromise, Observable } from 'rxjs'; +import { from, Observable } from 'rxjs'; import { first, map, share } from 'rxjs/operators'; import { Logger } from 'app/shared/logger.service'; @@ -20,7 +20,7 @@ export class PrettyPrinter { private prettyPrintOne: Observable; constructor(private logger: Logger) { - this.prettyPrintOne = fromPromise(this.getPrettyPrintOne()).pipe(share()); + this.prettyPrintOne = from(this.getPrettyPrintOne()).pipe(share()); } private getPrettyPrintOne(): Promise { diff --git a/aio/src/app/custom-elements/elements-loader.ts b/aio/src/app/custom-elements/elements-loader.ts index 8eef788c5b..b2ee24cf4f 100644 --- a/aio/src/app/custom-elements/elements-loader.ts +++ b/aio/src/app/custom-elements/elements-loader.ts @@ -5,9 +5,10 @@ import { NgModuleRef, } from '@angular/core'; import { ELEMENT_MODULE_PATHS_TOKEN } from './element-registry'; -import { from as fromPromise, Observable, of } from 'rxjs'; +import { from, Observable, of } from 'rxjs'; import { createCustomElement } from '@angular/elements'; + @Injectable() export class ElementsLoader { /** Map of unregistered custom elements and their respective module paths to load. */ @@ -34,7 +35,7 @@ export class ElementsLoader { // Returns observable that completes when all discovered elements have been registered. const allRegistered = Promise.all(unregisteredSelectors.map(s => this.loadCustomElement(s))); - return fromPromise(allRegistered.then(() => undefined)); + return from(allRegistered.then(() => undefined)); } /** Loads and registers the custom element defined on the `WithCustomElement` module factory. */ diff --git a/aio/src/app/custom-elements/toc/toc.component.ts b/aio/src/app/custom-elements/toc/toc.component.ts index b79736af07..dce71b3493 100644 --- a/aio/src/app/custom-elements/toc/toc.component.ts +++ b/aio/src/app/custom-elements/toc/toc.component.ts @@ -1,5 +1,5 @@ import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, QueryList, ViewChildren } from '@angular/core'; -import { asapScheduler as asap, combineLatest, Subject } from 'rxjs'; +import { asapScheduler, combineLatest, Subject } from 'rxjs'; import { startWith, subscribeOn, takeUntil } from 'rxjs/operators'; import { ScrollService } from 'app/shared/scroll.service'; @@ -52,7 +52,7 @@ export class TocComponent implements OnInit, AfterViewInit, OnDestroy { // We use the `asap` scheduler because updates to `activeItemIndex` are triggered by DOM changes, // which, in turn, are caused by the rendering that happened due to a ChangeDetection. // Without asap, we would be updating the model while still in a ChangeDetection handler, which is disallowed by Angular. - combineLatest(this.tocService.activeItemIndex.pipe(subscribeOn(asap)), this.items.changes.pipe(startWith(this.items))) + combineLatest(this.tocService.activeItemIndex.pipe(subscribeOn(asapScheduler)), this.items.changes.pipe(startWith(this.items))) .pipe(takeUntil(this.onDestroy)) .subscribe(([index, items]) => { this.activeIndex = index;