-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
fix: ensure migrate keeps inline/trailing comments in $props type definition and produces non-broken code #14143
fix: ensure migrate keeps inline/trailing comments in $props type definition and produces non-broken code #14143
Conversation
… let types to type definition
🦋 Changeset detectedLatest commit: e00d318 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Thank you! Could you add a changeset? Then we're good to merge |
commit: |
Changeset added! |
Just one comment...while a bit weird unfortunately you can't assume trailing comments are only line comment. For example this <script>
export let name = 'world'; /*
* this is a trailing comment too
**/
</script> migrate to broken code <script>
/**
* @typedef {Object} Props
* @property {string} [name] - * this is a trailing comment too
*
*/
/** @type {Props} */
let { name = 'world' } = $props();
* this is a trailing comment too
**/
</script> although to be fair it's broken in today migration too...but the comment should probably undergo the same "cleaning" process we apply to the leadingComments |
…broken code, FIXES PR sveltejs#14143#issuecomment-2455702689
… same-line leading multiline comments
@paoloricciuti Nice catch! Absolutely fair to fix it while we're at it and add tests, especially when it produces broken code. I have modified this PR with the fix (and reworked comment parsing a bit so that it's exactly like leadingComments) and added tests for the use case you mentioned. Adding a new patch fix to the changeset as well, since the issue predates my PR (and arguably is more important than the original issue!). |
preview: https://svelte-dev-git-preview-svelte-14143-svelte.vercel.app/ this is an automated message |
@rgon if you can fix linting we are good to merge |
It was a small issue in the migrate file...let's wait on all greens and i'll merge |
@paoloricciuti thanks, I got a bit confused with the |
Thanks! 🚀 |
Fixes #14140
Keeps inline comments when migrating types, as we already do with other statement types L783
Added tests for Typescript and JSDoc migration. In the latter, the comments are merged with leading comments. See
tests/migrate/jsdoc-with-comments/output.svelte