Function expressions are not supported in decorators
edrorr opened this issue · comments
Hello,
I have installed ngx-highlight.js and following the provided instructions added this providers to my module
{
provide: HIGHLIGHT_OPTIONS,
useValue: {
coreLibraryLoader: () => import('highlight.js/lib/core'),
lineNumbersLoader: () => import('highlightjs-line-numbers.js'), // Optional, only if you want the line numbers
languages: {
xml: () => import('highlight.js/lib/languages/xml')
}
}
}
but when i run the project this errors are appearing :
Function expressions are not supported in decorators
Consider changing the function expression into an exported function.
so i have used the export function instead. but
export function loadHighlightJs() {
return () => import('highlight.js/lib/core');
}
and changed the useValue inside provider to this :
coreLibraryLoader: loadHighlightJs()
The error is gone but HighlightJs is not working and i have this error in the browser Console :
[HLJS] Highlight.js library was not imported!
OS and Version?
Windows 10
Versions
@angular/cli 10.2.0
node 12.19.0
npm 6.14.8
The issue is probably with the project setup you have, could be because the typescript version you are using... try it out with a a new angular project
Did you ever fix this?
I am having the same issue.
Typescript 3.9.7
Angular 10.0.14
Angular CLI 10.0.8
@matthewdolman No unfortunately i didn't had time and ended up importing the js file in angular.json
try
coreLibraryLoader: loadHighlightJs
instead of
coreLibraryLoader: loadHighlightJs()
@matthewdolman No unfortunately i didn't had time and ended up importing the js file in angular.json
hii, iam getting the same error, what js do i need to add in angular.json file, iam using angular version 8
providers: [
{
provide: HIGHLIGHT_OPTIONS,
useValue: {
coreLibraryLoader: coreLibraryLoader,
lineNumbersLoader: lineNumbersLoader, // Optional, only if you want the line numbers
languages: {
json: languageJSON
}
}
}
]
app.module.ts
providers: [ { provide: HIGHLIGHT_OPTIONS, useValue: { coreLibraryLoader: coreLibraryLoader, lineNumbersLoader: lineNumbersLoader, // Optional, only if you want the line numbers languages: { json: languageJSON } } } ]
app.module.ts
i tried this way, and its says Highlight.js library was not imported! in browser console