Skip to content

Commit

Permalink
chore: fix docs app console errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jakovljevic-mladen committed Oct 24, 2021
1 parent 951f584 commit 7a811d5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions docs_app/src/app/custom-elements/code/pretty-printer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import { first, map, share } from 'rxjs/operators';

import { Logger } from 'app/shared/logger.service';

declare const System: {
import(name: string): Promise<any>;
};

type PrettyPrintOne = (code: string, language?: string, linenums?: number | boolean) => string;

/**
Expand All @@ -24,12 +20,13 @@ export class PrettyPrinter {
}

private getPrettyPrintOne(): Promise<PrettyPrintOne> {
const ppo = (window as any)['prettyPrintOne'];
const ppo = (window as any).prettyPrintOne;
return ppo ? Promise.resolve(ppo) :
// prettify.js is not in window global; load it with webpack loader
System.import('assets/js/prettify.js')
// `prettyPrintOne` is not on `window`, which means `prettify.js` has not been loaded yet.
// Import it; as a side-effect it will add `prettyPrintOne` on `window`.
import('assets/js/prettify.js' as any)
.then(
() => (window as any)['prettyPrintOne'],
() => (window as any).prettyPrintOne,
err => {
const msg = `Cannot get prettify.js from server: ${err.message}`;
this.logger.error(new Error(msg));
Expand Down

0 comments on commit 7a811d5

Please sign in to comment.