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 63b6fa69b3..24538d8702 100644 --- a/aio/src/app/custom-elements/code/pretty-printer.service.ts +++ b/aio/src/app/custom-elements/code/pretty-printer.service.ts @@ -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; -}; - type PrettyPrintOne = (code: string, language?: string, linenums?: number | boolean) => string; /** @@ -26,8 +22,9 @@ export class PrettyPrinter { private getPrettyPrintOne(): Promise { 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; ad a side-effect it will add `prettyPrintOne` on `window`. + import('assets/js/prettify.js' as any) .then( () => (window as any)['prettyPrintOne'], err => {