question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to model Typescript `type`s not just interface and Classes

See original GitHub issue

I am using types instead of interfaces and classes eg.

type Something = {
   name: string
   value: number
   user: User
}```

with many types containing other types (eg. a hierarchy similar to the demo) but when running tsuml I get the following (as though it can't parse it, but it is valid Typescript):

render to svg Error: Parse error on line 3:

^ Expecting ‘IDENT’, ‘[’, got ‘EOF’ Error: Parse error on line 3:

^ Expecting ‘IDENT’, ‘[’, got ‘EOF’ at Parser.parseError (/Users/…/node_modules/nomnoml/dist/nomnoml.js:806:25) at Parser.parse (/Users/…/node_modules/nomnoml/dist/nomnoml.js:867:26) at intermediateParse (/Users/…/node_modules/nomnoml/dist/nomnoml.js:1392:34) at parse (/Users/…/node_modules/nomnoml/dist/nomnoml.js:1312:25) at parseAndRender (/Users/…/node_modules/nomnoml/dist/nomnoml.js:2159:29) at Object.renderSvg (/Users/…/node_modules/nomnoml/dist/nomnoml.js:2175:34) at renderNomnomlSVG (/Users/…/node_modules/tsuml2/dist/core/io.js:30:20) at createNomnomlSVG (/Users/…/node_modules/tsuml2/dist/core/index.js:93:41) at /Users/…/node_modules/tsuml2/dist/bin/index.js:18:41 at Object.<anonymous> (/Users/…/node_modules/tsuml2/dist/bin/index.js:24:3) { hash: { text: ‘’, token: ‘EOF’, line: 2, loc: { first_line: 1, last_line: 3, first_column: 0, last_column: 0 }, expected: [ “‘IDENT’”, “‘[’” ] } }```

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
demikecommented, Jun 13, 2022

@rpocklin member associations can be rendered now in v0.6.1 If the member is an array “0…*” is added in addition to the assocation line. Would be nice if you can try it out use the -m command line parameter

And thanks for the constructive comments

1reaction
demikecommented, May 18, 2022

That’s what I call a minimal reproduction 👍 In this case the problem was that not a single entity could be emitted and therefore nomnoml complained about that.

Now an error message will be shown in such a case.

By the way

export type X =
  | "a"
  | "b"

will not produce an entity now (open for suggestions). For now only types like

export type T = {
  a: number;
  doSomething(): void;
}

will produce output.

Can you give 0.5.1 a try

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript - Class or Interface for Model?
Practically, both Class and Interface can be used interchangeably as "type" in TypeScript. But just because it can be done, does not necessarily...
Read more >
Classes vs Interfaces in TypeScript
Classes and interfaces are powerful structures that facilitate not just object-oriented programming but also type-checking in TypeScript.
Read more >
Types vs. interfaces in TypeScript
1. “In TypeScript, we can easily extend and implement interfaces. This is not possible with types though.” What? Classes can implement types.
Read more >
Handbook - Interfaces
Interfaces are capable of describing the wide range of shapes that JavaScript objects can take. In addition to describing an object with properties,...
Read more >
When use a interface or class in Typescript [duplicate]
Classes and interfaces are powerful structures that facilitate not just object-oriented programming but also type-checking in TypeScript.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found