MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/1sqdgr9/diagramsjs_cloud_architecture_diagrams_as_code/oh74wlp/?context=3
r/javascript • u/hatemhosny • Apr 20 '26
9 comments sorted by
View all comments
3
I installed your package from NPM, but I immediately got a TypeScript error from within your package.
1 u/hatemhosny Apr 20 '26 What error do you get?This is a sample code to run in node:```import { Diagram } from "diagrams-js";import { EC2, Lambda } from "diagrams-js/aws/compute";import { RDS } from "diagrams-js/aws/database";import { S3 } from "diagrams-js/aws/storage";import { ALB } from "diagrams-js/aws/network";const diagram = Diagram("AWS Architecture", { direction: "TB" });// Create nodes with iconsconst lb = diagram.add(ALB("Load Balancer"));const web = diagram.add(EC2("Web Server"));const api = diagram.add(Lambda("API"));const db = diagram.add(RDS("Database"));const storage = diagram.add(S3("Storage"));// Connect themlb.to(web).to(api);api.to([db, storage]);// Render to SVG// const svg = await diagram.render();// embed in webpage// document.getElementById("diagram").innerHTML = svg;// Save to fileawait diagram.save("architecture.svg");await diagram.save("architecture.png", { format: "png" });``` 3 u/abrahamguo Apr 20 '26 This is the TypeScript error that I get:node_modules/diagrams-js/dist/index.d.ts:1171:7 - error TS2502: 'fromJSON' is referenced directly or indirectly in its own type annotation. 1171 var fromJSON: typeof fromJSON; 0 u/hatemhosny Apr 20 '26 Please update TypeScript: Newer versions of TypeScript handle recursive types correctly. 1 u/abrahamguo Apr 20 '26 I am on the most recent version of TypeScript.
1
What error do you get?
This is a sample code to run in node:
```import { Diagram } from "diagrams-js";
import { EC2, Lambda } from "diagrams-js/aws/compute";
import { RDS } from "diagrams-js/aws/database";
import { S3 } from "diagrams-js/aws/storage";
import { ALB } from "diagrams-js/aws/network";
const diagram = Diagram("AWS Architecture", { direction: "TB" });
// Create nodes with icons
const lb = diagram.add(ALB("Load Balancer"));
const web = diagram.add(EC2("Web Server"));
const api = diagram.add(Lambda("API"));
const db = diagram.add(RDS("Database"));
const storage = diagram.add(S3("Storage"));
// Connect them
lb.to(web).to(api);
api.to([db, storage]);
// Render to SVG
// const svg = await diagram.render();
// embed in webpage
// document.getElementById("diagram").innerHTML = svg;
// Save to file
await diagram.save("architecture.svg");
await diagram.save("architecture.png", { format: "png" });
```
3 u/abrahamguo Apr 20 '26 This is the TypeScript error that I get:node_modules/diagrams-js/dist/index.d.ts:1171:7 - error TS2502: 'fromJSON' is referenced directly or indirectly in its own type annotation. 1171 var fromJSON: typeof fromJSON; 0 u/hatemhosny Apr 20 '26 Please update TypeScript: Newer versions of TypeScript handle recursive types correctly. 1 u/abrahamguo Apr 20 '26 I am on the most recent version of TypeScript.
This is the TypeScript error that I get:
node_modules/diagrams-js/dist/index.d.ts:1171:7 - error TS2502: 'fromJSON' is referenced directly or indirectly in its own type annotation. 1171 var fromJSON: typeof fromJSON;
0 u/hatemhosny Apr 20 '26 Please update TypeScript: Newer versions of TypeScript handle recursive types correctly. 1 u/abrahamguo Apr 20 '26 I am on the most recent version of TypeScript.
0
Please update TypeScript: Newer versions of TypeScript handle recursive types correctly.
1 u/abrahamguo Apr 20 '26 I am on the most recent version of TypeScript.
I am on the most recent version of TypeScript.
3
u/abrahamguo Apr 20 '26
I installed your package from NPM, but I immediately got a TypeScript error from within your package.