dts2hx
dts2hx copied to clipboard
Dependency not picked up for module 'fastify'
I tried to generate extern for fastify by
npx dts2hx fastify --output lib/dts2hx
It outputted a bunch of errors:
> Converting module fastify
> Error: [TypeScript 3.7] Cannot find module 'http'. (/workspace/node_modules/fastify/fastify.d.ts:1:23)
> Error: [TypeScript 3.7] Cannot find module 'http2'. (/workspace/node_modules/fastify/fastify.d.ts:2:24)
> Error: [TypeScript 3.7] Cannot find module 'https'. (/workspace/node_modules/fastify/fastify.d.ts:3:24)
> Error: [TypeScript 3.7] Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig. (/workspace/node_modules/fastify/types/content-type-parser.d.ts:11:28)
> Error: [TypeScript 3.7] Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig. (/workspace/node_modules/fastify/types/content-type-parser.d.ts:43:29)
...
I tried installing @types/node and running npx dts2hx @types/node fastify --output lib/dts2hx, but that didn't help. Am I missing something?
My dts2hx version:
dts2hx 0.15.3 alpha using TypeScript 3.7.4
hmm, not sure why it's not picking up the node dependency automatically, to resolve in the short term, open
node_modules/fastify/fastify.d.ts and add /// <reference types="node" /> to the very top. Do the same for light-my-request/index.d.ts
Then run npx dts2hx fastify and it will work
I will explore what went wrong for it to miss the node dependency here