Skip to content

Some fixes #6

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

Merged
merged 12 commits into from
Apr 26, 2022
Merged

Some fixes #6

merged 12 commits into from
Apr 26, 2022

Conversation

milahu
Copy link
Contributor

@milahu milahu commented Apr 14, 2022

fix #5
maybe fix #4

@milahu milahu force-pushed the some-fixes branch 2 times, most recently from cfc653b to b11251c Compare April 14, 2022 09:35
@futurGH
Copy link
Owner

futurGH commented Apr 15, 2022

Thanks for the contribution! This looks great for the most part; frankly more effort than I put into what was really just a throwaway script I decided to publish.

index.ts Outdated
Comment on lines 103 to 106
/**
* Generate @returns documentation from function return type
* the new jsDoc is stored in functionNode
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Generate @returns documentation from function return type
* the new jsDoc is stored in functionNode
*/
/** Generate @returns documentation from function return type and attach it to functionNode */

Good idea to include this info, though it doesn't need to be on a separate line. Same goes for the other instances where this line was added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh come on .... ^^

index.ts Outdated
Comment on lines 327 to 329
`internal error: protectCommentsHeader is missing in output\n\n` +
`protectCommentsHeader: ${JSON.stringify(protectCommentsHeader)}\n` +
`result: ${JSON.stringify(result.slice(protectCommentsHeader.length + 100) + " ...")}`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`internal error: protectCommentsHeader is missing in output\n\n` +
`protectCommentsHeader: ${JSON.stringify(protectCommentsHeader)}\n` +
`result: ${JSON.stringify(result.slice(protectCommentsHeader.length + 100) + " ...")}`
`Internal error: generated header is missing in output\n\n` +
`protectCommentsHeader: ${JSON.stringify(protectCommentsHeader)}\n` +
`result: ${JSON.stringify(result.slice(protectCommentsHeader.length + 100) + " ...")}`

Likely less confusing to avoid mentioning the variable name in the error message; why does the header need to be JSON.stringif[ied]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helpful for debugging, when ts-morph/typescript returns an unexpected value
we want to remove exactly what we added

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was referring to JSON.stringify(protectCommentsHeader). Since it's a defined constant variable where we know its content, in what scenario would the JSON.stringify call produce a more desirable output than just including the variable without the wrapping function call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exact diff

@milahu
Copy link
Contributor Author

milahu commented Apr 15, 2022

just a throwaway script

yeah ... i wanted to throw this at patch-package to remove typescript, but keep types in jsdoc comments

but ultimately, the typescript syntax is better, and compiling is fast enough
(also there is deno to run typescript directly)
(also javascript has no nested block comments, and triple slash jsdoc comments are not implemented)

i also tried to patch ts-morph to make every TypedNode also a JSDocableNode
but i had no success in monkey-patching the import
probably we would need to patch the ts-morph source, as in dsherret/ts-morph#193

@futurGH
Copy link
Owner

futurGH commented Apr 15, 2022

Ah, I wasn't sure if the lack of JSDocableNode was intentional on ts-morph's end when I wrote this. I don't foresee much change to this codebase, so I think we're fine with the custom intersection type and perhaps less-than-ideal assertion given that it seems to work well enough. I might take another look at that if the assumption that every node ts-to-jsdoc touches is JSDocable starts causing errors, though.

@milahu
Copy link
Contributor Author

milahu commented Apr 16, 2022

lack of JSDocableNode was intentional on ts-morph's end

they implement a narrow spec of jsdoc (blocks: functions and classes)
but vscode can also parse jsdoc for statements

/** @type string */
let declaredVar;

declaredVar = 1;
// vscode settings.json
{
  "js/ts.implicitProjectConfig.checkJs": true
}

@milahu
Copy link
Contributor Author

milahu commented Apr 23, 2022

can we haz merge?

im not planning to do much more on this, as i dont need ts-to-jsdoc for now

@futurGH
Copy link
Owner

futurGH commented Apr 24, 2022

Sorry! I haven't had the time to take a look at this PR on my own machine yet — I think we can do without the tests for now considering that there still appears to be some work to be done there and I don't have the time to work on tests much myself. I'll try and merge in the rest soon.

@futurGH futurGH merged commit 06880b8 into futurGH:main Apr 26, 2022
@milahu
Copy link
Contributor Author

milahu commented Apr 27, 2022

thanks! : )

This was referenced Oct 25, 2022
Closed
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

Successfully merging this pull request may close these issues.

param is too verbose. should use only simple param names /usr/bin/env: ‘node\r’: No such file or directory
2 participants