Skip to content

Commit

Permalink
fix(docs-infra): workaround for broken 'import as' (#27536)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
IgorMinar authored and mhevery committed Dec 18, 2018
1 parent 2c9b6c0 commit cdfe8f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions aio/src/app/custom-elements/code/pretty-printer.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,7 +20,7 @@ export class PrettyPrinter {
private prettyPrintOne: Observable<PrettyPrintOne>;

constructor(private logger: Logger) {
this.prettyPrintOne = fromPromise(this.getPrettyPrintOne()).pipe(share());
this.prettyPrintOne = from(this.getPrettyPrintOne()).pipe(share());
}

private getPrettyPrintOne(): Promise<PrettyPrintOne> {
Expand Down
5 changes: 3 additions & 2 deletions aio/src/app/custom-elements/elements-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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. */
Expand Down
4 changes: 2 additions & 2 deletions aio/src/app/custom-elements/toc/toc.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit cdfe8f4

Please sign in to comment.