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.

Encapsulate the TypeScript parser into a separate lib

See original GitHub issue

Create a new project named TypeScript.SyntaxTreeParser and manually convert the TypeScript parser.ts bits into a C# TypeScript parser (from the compiler itself).

This library will be capable of representing TypeScript type declarations as an abstract syntax tree.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
IEvangelistcommented, May 4, 2023

I am curious how you managed to create those hundreds of classes. Were they generated somehow or were they hand-written?

Which classes specifically are you referring to? If you’re talking about the AST branch, then yes, those are hand-written.

Also is the intended work limited to porting parser.ts only or will it one day extend to other APIs like binder.ts, which is responsible for symbol resolution?

The intended work is to make a TypeScript type declaration parser capable of parsing raw .d.ts files and using this metadata to drive my C# source generator. I would define success as being able to source generate arbitrary files, outside the lib.dom.d.ts (which by the way no longer exists), and using that to generate types. As of right now, my project is already capable of source-generating services (interface and class C#), POCOs, and dependency hierarchies.

0reactions
trungnt2910commented, May 4, 2023

My project manages to use JSImport because its JS interop architecture is fundamentally different, but that’s out of scope for this issue.

I am curious how you managed to create those hundreds of classes. Were they generated somehow or were they hand-written?

Also is the intended work limited to porting parser.ts only or will it one day extend to other APIs like binder.ts, which is responsible for symbol resolution?

Finally, please tell me if you know some documentation/guides on consuming the TypeScript compiler API from an outside program. I can find things like this but they mostly document the compiler internals and not how to consume those APIs like how one can use Roslyn.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript encapsulation demystified - Technical Blog at ...
Encapsulation is the perfect example of a mentioned different approach. At the Typescript level, you can use access modifiers public , protected ,...
Read more >
Should I try to enforce encapsulation in Typescript?
Lets assume I have an object which has an maintains an array of items. When working with this object I would like to...
Read more >
Employing “Namespaces” in TypeScript to encapsulate ...
In this lesson, we are going to learn about the precursor of the ECMAScript module implemented purely in TypeScript.
Read more >
Publishing Node modules with TypeScript and ES modules
Write and publish Node modules using TypeScript and ES modules so you can provide an easy experience for the consumers of your package....
Read more >
TSConfig Reference - Docs on every TSConfig option
Project references are a way to structure your TypeScript programs into smaller pieces. Using Project References can greatly improve build and editor ...
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