Typescript cannot locate the type information of the core module.
See original GitHub issueHi there 👋
I’d like to import the core and only necessary language files. I tried as below but then realised that there is something wrong in package regarding typings.
import hljs from 'highlight.js/lib/core'
import javascript from 'highlight.js/lib/languages/javascript'
Could not find a declaration file for module 'highlight.js/lib/core'.
I have not imported the index module i.e. import hljs from 'highlight.js
. So, typescript can’t locate the type information for the core module from a subfolder. I believe the solution might be creating .d.ts
file for every subfolder and file in your case.
I quickly fixed this issue locally by creating a core.d.ts
file under lib
directory. So, I guess we need to declare the entire API that the library exposes.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:37 (24 by maintainers)
Top Results From Across the Web
Cannot find module 'X' Error in TypeScript | bobbyhadz
The "Cannot find module or its corresponding type declarations" error occurs when TypeScript cannot locate a third-party or local module in our project....
Read more >Cannot find module 'react' or its corresponding type ...
When I change the file's extension to .js and .jsx from.ts and .tsx, the errors disappear. How should I solve this problem for...
Read more >Documentation - Module Resolution - TypeScript
This section assumes some basic knowledge about modules. Please see the Modules documentation for more information. Module resolution is the process the ...
Read more >TypeScript error in Visual Studio – Cannot find module ...
Experimental support for decorators is a feature that is subject to change in a future release. · Cannot find module '@angular/core' · Cannot...
Read more >How to fix error TS7016: Could not find a declaration file for ...
How to fix error TS7016: Could not find a declaration file for module 'XYZ'. 'file.js' implicitly has an 'any' type ... If you're...
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
FYI setting reference seems to play nice as near as I can tell.
In my case the file importing core is in src/filename.ts
From there register your languages:
@joshgoebel When I ran
cp -r /tmp/highlight.js/build ./node_modules/highlight.js
, it worked