highlight.js: typescript build problem: node_modules/highlight.js/types/index.d.ts is not a module

ts file content:

// index.ts
import * as hljs from 'highlight.js';

after I run command

tsc index.ts

I got error

index.ts:1:23 - error TS2306: File '/Users/limbo/tmp/ssss/node_modules/highlight.js/types/index.d.ts' is not a module.

1 import * as hljs from 'highlight.js';
                        ~~~~~~~~~~~~~~


Found 1 error.

The version I use is 10.1.0.

Try to use 10.0.2 and it build successfully.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 42 (26 by maintainers)

Commits related to this issue

Most upvoted comments

Same problems here. Suggest to refer to export from index.d.ts in @types/highlight.js:

declare namespace hljs {
 ...
}
export = hljs;
export as namespace hljs;

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/highlight.js/index.d.ts