Other potential Error source for "Error: Cannot find symbol for node: x"
See original GitHub issueHi,
first of all: thank for this great product.
tldr: Instead of using named imports use dynamic imports when hitting the “Cannot find symbol for node”-Error.
long version: I use it very intensive to create my definition files. I use it to create base packages, which get consumed by other packages, which get then get consumed by my projects.
When generating one of my base packages, which get consumed by another package, i got “Error: Cannot find symbol for node: amqplib”. I tried everything to figure out why it was erroring. installed everywhere @types/amqplib but could not solve the issue.
Then i set in tsconfig skipLibCheck to false and got a different error:
node_modules/project/amqp/types/index.d.ts(29,72): error TS2503: Cannot find namespace 'amqplib'.
node_modules/project/amqp/types/index.d.ts(49,20): error TS2304: Cannot find name 'Channel'.
node_modules/project/amqp/types/index.d.ts(69,53): error TS2503: Cannot find namespace 'amqplib'.
node_modules/project/amqp/types/index.d.ts(71,21): error TS2503: Cannot find namespace 'amqplib'.
node_modules/project/amqp/types/index.d.ts(77,46): error TS2503: Cannot find namespace 'amqplib'.
node_modules/project/amqp/types/index.d.ts(78,52): error TS2503: Cannot find namespace 'amqplib'.
Channel is an interface from amqplib.
I was importing it by doing
import { Channel } from amqplib;
And was referenced by Channel
.
So I changed the named import to a dynamic import.
import * as amqplib from amqplib;
And referenced it as amqplib.Channel
.
And then dts-bundle-generator worked as expected.
Seems like dts-bundle-generator does not like named imports for types. Or maybe it fails in tsc. Not important where 😉.
I dont know if this was already explicitly documented, but I strongly recommend to document it. Took some time to figure it out by myself, and all the other search results were not hinting to this problem. So if somebody hits the same issue, he/she should first check for potential named imports and change them to dynamic imports.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Hi timocov,
I have to admin: No. I learn from this issue, that I should encapsulate my plugins better, so that I wont need any external typings anymore.
I close this issue, as it was a result of bad practice anyway.
Thank you for your time! Thanks again for the great product!
@Uzlopak do you have any news?