Skip to content
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

Issues in generated files #6

Closed
no-more opened this issue Sep 20, 2016 · 10 comments
Closed

Issues in generated files #6

no-more opened this issue Sep 20, 2016 · 10 comments

Comments

@no-more
Copy link

no-more commented Sep 20, 2016

Hi,

I'm just a user of forerunnerdb and they are using your tool to generate their types.d.ts file
I have pointed out a few issues on the generated file.

The generated file is here : https://github.com/Irrelon/ForerunnerDB/blob/master/typescript/types.d.ts

I would like to check with you if this is a bug in this tool, or maybe it's possible to improve their jsdoc in order to fix those generation issues.

Thanks for your help.

@englercj
Copy link
Owner

Can you point me to the source that generates the bad TS? usually if there is no generic arg to the Array class, it is because there was no type specification in the source jsdoc.

@no-more
Copy link
Author

no-more commented Sep 20, 2016

Hi,

This is the input file (I think) : https://raw.githubusercontent.com/Irrelon/ForerunnerDB/master/js/dist/fdb-all.js
the online doc is here : https://www.forerunnerdb.com/source/doc/index.html
As you've said Array are untyped. I don't know much about jsdoc, what should the doc specify in order to return any[] in the typescript definition file ? Is it "Array.any" ?
Is it possible to automatically change "Array" to any[] when no type is specified ? tslint complains about Array without type.

Thanks.

@englercj
Copy link
Owner

englercj commented Sep 20, 2016

Yeah we can assume any[] for untyped Array's. The idea behind not doing that would be that the TS errors you got would make you go back and type your arrays properly in the docs. Because generally invalid TS output means invalid jsdoc.

I'll add an option that can be opted into that will fill holes like this with any types.

@englercj
Copy link
Owner

As for the other one (types inside of class declarations) that is definitely a bug here. According to this what I need to do is queue up these types and add them to a namespace of the same name as the class.

Thanks for bringing this up!

@aendra-rininsland
Copy link

@englercj Confirming that approach solves the issue — I moved the types generated inside classes into a namespace of the same name as the class and it seems to make everything work, at least in terms of how github-api uses JSDoc. Happy to PR it, though be forewarned I am very new to the JSDoc plugin API!

@englercj
Copy link
Owner

englercj commented Oct 5, 2016

Np, I'm working on v2 now. It adds some TS 2 features, uses a better emitter, and fixes a lot of these types of bugs.

I should have it done over the next week or two (see #7).

@jmls
Copy link

jmls commented Dec 13, 2016

I take it v2 is not yet released ? ;)

@englercj
Copy link
Owner

Nope, haven't had time to come back to this; been extremely busy at work.

@englercj
Copy link
Owner

englercj commented Feb 6, 2017

Getting closer on this, just a few more things to work out and I should be able to release v2 soon. Sorry its been so long :(

@englercj
Copy link
Owner

Got the module declaration stuff working for inner classes and types, as well as fixing array/object definitions.

I'll put out a v2 beta build shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants