I'm using Visual Studio 2015 to create Web Apps and I just start using TypeScript
.
As my project gets bigger, I'm wondering if there's a way to get UML diagram of TypeScript
code using Visual Studio, extensions or any other free tool.
I'm using Visual Studio 2015 to create Web Apps and I just start using TypeScript
.
As my project gets bigger, I'm wondering if there's a way to get UML diagram of TypeScript
code using Visual Studio, extensions or any other free tool.
I am using a VSC extension named classdiagram-ts from AlexShen that does a very nice job, it can be used for creating a diagram for a file or a folder and also lets you reposition and navigate to fields, hide members and other cool options.
https://marketplace.visualstudio.com/items?itemName=AlexShen.classdiagram-ts&ssr=false#overview
You can try tplant. Here's an example for the typescript classes at https://github.com/pascalerni/abap2famix/tree/master/src
Another alternative, which I currently use but requires VSCode, is: vscode-ts-uml
I would advise against doing anything with TsUML. You install it as a regular NPM package, but then it uses some sketchy online service. It seems dangerous to use Tsuml for proprietary projects.
for Visual Studio : https://marketplace.visualstudio.com/items?itemName=AzadRatzki.TypeScriptDiagram#overview
for vscode : https://github.com/remojansen/TsUML
or
I would suggest commenting your TypeScript code using the JSDoc convention, compile your TS code without stripping off comments (removeComments to false in tsconfig.json), and use a documentation generator on the JS files.
Based on that, you could maybe find a tool to generate UML diagram from JSDoc : JSDoc UML Diagram
Using TsUML:
npm install -g tsuml
# Note: this posts data to https://yuml.me!!
tsuml --glob ./src/**/*.ts
I found a very useful site to convert TS to UML diagram
https://tsuml-demo.firebaseapp.com/
copy following code and paste it under Typescript Tab
export class BaseDTO {
created: number;
createdBy: string;
updated: number;
updatedBy: string;
}
export class PaymentDTO extends BaseDTO {
paymentId: number;
paymentReference: string;
amount: string;
paymentPayee: { name: string }
}
Example:
There is now an open-source package called TsUML2 that, in their words:
works offline, so no third party servers are involved.