Highlight.js requires Typescript users to set `esModuleInterop` to true.
See original GitHub issueDescribe the issue/behavior that seems buggy
To use highlight.js without typescript complaining, I need to do:
import hljs from 'highlight.js`
hljs.highlight(/* etc */)
However, this gives me an error that hljs is undefined
.
To fix this, I need to do this:
import * as hljs from 'highlight.js`
// @ts-ignore-error
hljs.highlight(/* etc */)
I think this is because typescript expects you to export an object with a propertyname default
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:24 (12 by maintainers)
Top Results From Across the Web
TSConfig Option: esModuleInterop - TypeScript
the ES6 modules spec states that a namespace import ( import * as x ) can only be an object, by having TypeScript...
Read more >24 - Stack Overflow
As the error states, you need the set "esModuleInterop": true,. in your tsconfig.json file. This allows default imports from modules with no ...
Read more >How To Use Modules in TypeScript | DigitalOcean
There are two ways to solve this: Using import = require() and setting the esModuleInterop property to true in the TypeScript Compiler ...
Read more >Building Lambda functions with TypeScript
You can use the Node.js runtime to run TypeScript code in AWS Lambda. Because Node.js doesn't run TypeScript code natively, you must first...
Read more >The Complete Guide to Day.js - Mirza Leka - Medium
npm i dayjs // install dayjs. And require it in your app: const dayjs = require('dayjs');. The process is similar in the TypeScript...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Published with 11.3
Ping. @manuth