-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix: allow to pass in TS preference to migration #13929
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
Conversation
First half of sveltejs/kit#12880 - the idea is for the migration script to check for a tsconfig.json and then set it to `true` if one is found
🦋 Changeset detectedLatest commit: dd148cd 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 |
commit: |
Fixes #12880, relies on sveltejs/svelte#13929
) | ||
uses_ts: | ||
// Some people could use jsdoc but have a tsconfig.json, so double-check file for jsdoc indicators | ||
(use_ts && !source.includes('@type {')) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be more thorough using a regex. It won't pass if you had:
/**
* @template T
* @param {T} thing
* @returns {T}
*/
For example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with these is that I have seen these appear above typescript functions in the wild. @type
on the other hand is a pretty strong indicator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. However, if someone specifies use_ts
to be true
or false
, shouldn't that precedence over a check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they use JSDoc wouldn't they omit the lang="TS"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they use JSDoc wouldn't they omit the lang="TS"?
Yes, which is why there's the outer ||
in which case we see "this is definitely TS because the lang tag is set". This is only about the ambiguity of people using JSDoc but having a tsconfig.json
Makes sense. However, if someone specifies use_ts to be true or false, shouldn't that precedence over a check?
It will be set to true
or false
by svelte-migrate
in sveltejs/kit#12881 based on the presence (or absence) of tsconfig.json, which as pointed out above does not necessarily mean you're using TS, so the check is still needed
…nd (#12881) Fixes #12880, relies on sveltejs/svelte#13929
First half of sveltejs/kit#12880 - the idea is for the migration script to check for a tsconfig.json and then set it to
true
if one is foundBefore submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint