Problem with NodeList in index.d.ts in node.js project
See original GitHub issueI have a node.js based TypeScript project. ohm is installed using npm. Running tsc -p
throws an error:
node_modules/ohm-js/index.d.ts(39,16): error TS2304: Cannot find name 'NodeList'.
I guess because NodeList is browser specific. Commenting out the grammarFromScriptElements
function signature in index.d.ts makes it compile again.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
node_modules/@types/node/index.d.ts(20,1): error TS1084
My solution is to change typescript version to '>=2.7.3'. I think the version might depend on other packages. probably need to try a...
Read more >A Complete Guide to Using TypeScript in Node.js - Better Stack
JavaScript library authors can ensure that their packages are type-checked when utilized in a TypeScript project by providing type declaration files ( .d.ts...
Read more >NodeList - Web APIs | MDN
Chrome Edge Fir...
NodeList Full support. Chrome1. Toggle history Full support. Edge12. Toggle history Fu...
@@iterator Full support. Chrome51. Toggle history Full support. Edge79. Toggle...
Read more >types/jsdom/index.d.ts - UNPKG
* The built-in `vm` module of Node.js is what underpins JSDOM's script-running magic. 49, * Some advanced use cases, like pre ...
Read more >Web Scraping with TypeScript and Node.js - This Dot Labs
For simplicity, we'll create an index.ts file in the project root to ... project # install dependencies npm install typescript ts-node npm ......
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 FreeTop 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
Top GitHub Comments
That would be great.
Hmm, ok. So for your use case, you’d prefer that the Ohm definitions don’t refer to any types from the DOM library, right?
I think maybe the solution is to do something similar to what ProtoBuf.js does: you should be able to choose to use a subset of the API that doesn’t include any browser-related features. E.g.,
import * as ohm from 'ohm-js/no-dom';
.