question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Highlight.js requires Typescript users to set `esModuleInterop` to true.

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:24 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
joshgoebelcommented, Oct 17, 2021

Published with 11.3

1reaction
joshgoebelcommented, Oct 6, 2021

Ping. @manuth

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found