-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript support #282
Comments
We've started documenting Flow compatibility in GETTING_STARTED https://github.com/documentationjs/documentation/blob/master/docs/GETTING_STARTED.md#flow-type-annotations but need more TypeScript examples, as well as a bit of context for what's the overlap & difference between the two syntaxes. The gist is that documentation.js is able to infer parameter types from Flow type annotations, so that you can omit JSDoc-style type descriptions. It can also transform typedef statements into typedefs in documentation, again with inferred property types. The technical guts of this transformation are in flow_doctrine, that translates typeAnotation AST nodes (as parsed by Babel) into type objects like doctrine would export. |
Reading into this, we do need to make it clear that the scope is supporting TypeScript type annotations, where they overlap with Flow and not support for everything in TypeScript. Babel can't parse TypeScript, so we can't. |
Babel listed TypeScript support in the potential future plans of their update. It's probably still a ways out, though, and as before Babel's support is necessary for documentationjs's support. |
I'm going to make the call to cut TypeScript support as a TODO right now. I'd be happy and overjoyed to review and accept a PR implementing support, but given the mountain of other things to work on, it isn't something I can realistically say I can do in 2017. |
Hi! Babylon supports typescript if you enable the matching plugin. It works really well: prettier's typescript support is based on it. I'll try updating documentationjs' babylon version, and parsing settings. As I am unfamiliar with how this project works, do you think this will be enough, or would it require significant changes to code using the parser? |
It depends on what AST we get. Is there an overlap between the Flow an TS AST? |
Unfortunately, it seems not. They're quite different, so I guess another doctrine would be required? Here is the partial result for a simple test class:
(This requires babylon@7.0.0beta, and you can't use the "flow" and "typscript" plugins at the same time) |
So, I gave it a shot and it looks like there's a lot of work figuring out what the AST looks like before getting something out. I don't think that the issue should be reopened. |
For those looking for a typescript documentation generator there is one here. Though even if you are using typescript you can still run documentation on your generated js file. |
typedoc is really weak, and doesn't support almost any of what you need in a real documentation generator. can't even make public and private documentation in the meantime typescript has mostly won, and is expected to represent es8's possible type system |
@tmcw what would it take to add typescript support today (generally, not specifically today)? would be very cool to use this on one of my large typescript codebases, so i'm motivated to contribute but i don't know where to start? it seems like babylon's support for typescript may have improved, so perhaps this is worth reinvestigating. |
Sure, that's be great! I can't be 100% of sure what's required without implementing it, but what I expect is:
I'm not up-to-speed on step (1), whether babylon is now good at TypeScript parsing. If so - and if that's only in babylon 7, that means this task would encompass #996, the update to the Babel 7 ecosystem. |
TSDoc may be interesting in this context. See also Format TSDoc: A TypeScript Source Code Documentation Format. |
Now that Babel can parse Typescript via |
nope. all that does is strip the typescript out |
@babel/plugin-transform-typescript did not parse typescript. But babylon(renamed to babel-parser), which used by babel v7 and by |
Any updates on this? :-) Would love to migrate one of my projects to TypeScript, but most of the documentation is auto-generated using this awesome project and I don't want to loose that. 😄 Happy to help, in case there are clear deliverables to make this happen (not familiar with the documentationjs code base, yet). Edit, just became aware of this: https://github.com/tgreyuk/typedoc-plugin-markdown |
There's a proposed solution here: jsdoc/jsdoc#272 (comment), using jsdoc-babel and @babel/preset-typescript. I tried typedoc+typedoc-plugin-markdown recently, and unfortunately it fails if you need |
soo...? any news? Does ts work now with documentationjs? |
I am working on TypeScript support. See WIP PR here: #1234 |
@devongovett great job! But are there any examples or example project where I can find how to properly use or configure the project? I've tried to use documentation just as usual |
@SkeLLLa Please open a new issue and follow the issue template, including details like the source code you're using, and whether you've added documentation comments, and so on. Please don't tag onto existing issues with vague reports. |
Hi there,
is it possible to use
documentation
with TypeScript? If not, are there any plans to support it?The text was updated successfully, but these errors were encountered: