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

Incorrect handling of newlines in /** */-style docstrings #38

Open
epatters opened this issue Jul 19, 2024 · 5 comments
Open

Incorrect handling of newlines in /** */-style docstrings #38

epatters opened this issue Jul 19, 2024 · 5 comments

Comments

@epatters
Copy link

epatters commented Jul 19, 2024

When tsify generates a doctring for a type definition, any newlines in the Rust doc comments appear as "\n" (two characters, "\" and "n") in the TypeScript docstring.

@siefkenj
Copy link
Owner

Hmmm. I know this was an issue with an old version of rust-analyzer. Can you verify that the produced .d.ts files have the \ and n in them?

@epatters
Copy link
Author

epatters commented Jul 23, 2024

I can confirm that, for this type, I'm seeing the characters \ and n in sequence in the generated .d.ts file. The long, multi-line doc-comment ends up as a one-line doc-string with the newlines appearing as \n.

Sorry, I know that's not a very self-contained example. I can try to produce a minimal example if it's helpful.

@siefkenj
Copy link
Owner

Can you test whether it still happens if you use triple slash /// for the doc comments?

@epatters
Copy link
Author

That fixed it!

@siefkenj
Copy link
Owner

Great! I will leave this issue open because it really should work with /** */ style comments as well, but at least there is a workaround.

Let me know if you're interested in looking into a PR for this.

@siefkenj siefkenj changed the title Incorrect handling of newlines in docstrings Incorrect handling of newlines in /** */-style docstrings Jul 23, 2024
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

2 participants