-
Notifications
You must be signed in to change notification settings - Fork 223
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
ts-migrate is inserting comments in JSX components #150
Comments
Looking at function isReactSfcFunctionDeclaration(functionDeclaration) {
return (functionDeclaration.name != null &&
/^[A-Z]\w*$/.test(functionDeclaration.name.text) &&
functionDeclaration.parameters.length <= 2); // <--------------
} I tried handling the |
I'm experiencing the same problem. I tried to pinpoint the problem by stepping through with the debugger, but I was unable to find the point of failure. I changed versions of TypeScript to see if that could be the issue, and found the issue does not exist when using v4.2.4. With this version, I get the expected output after running export default ({
name
}: any) => {
return (
// @ts-expect-error ts-migrate(7026) FIXME: JSX element implicitly has type 'any' because no i... Remove this comment to see the full error message
<div>
{/* @ts-expect-error ts-migrate(7026) FIXME: JSX element implicitly has type 'any' because no i... Remove this comment to see the full error message */}
<div>Hello, {name}!</div>
{/* @ts-expect-error ts-migrate(7026) FIXME: JSX element implicitly has type 'any' because no i... Remove this comment to see the full error message */}
</div>
)
} With versions 4.3.2 and 4.4.4, I get the following: export default ({
name
}: any) => {
return (
// @ts-expect-error ts-migrate(7026) FIXME: JSX element implicitly has type 'any' because no i... Remove this comment to see the full error message
<div>
// @ts-expect-error ts-migrate(7026) FIXME: JSX element implicitly has type 'any' because no i... Remove this comment to see the full error message
<div>Hello, {name}!</div>
// @ts-expect-error ts-migrate(7026) FIXME: JSX element implicitly has type 'any' because no i... Remove this comment to see the full error message
</div>
)
} |
Good detective work thank you! I'm sure this will help others a great deal, editing the hundreds of comments by hand was not fun at all :] |
Also seeing exactly these issues: normal javascript Tried rolling back to |
I am noticing that this only happens on the last comment of each file. I have a number jsx files that generate +20 typescript 4.8.4 Edit: Its seems to be adding |
I think there might be two related issues here:
|
- inJsxText would always return false if the position it was given was a closing tag. This caused ts-ignore to not properly comment @ts-expect-error messages when they were added to tsx files. - Issue airbnb#150
- inJsxText would always return false if the position it was given was a closing tag. This caused ts-ignore to not properly comment @ts-expect-error messages when they were added to tsx files. - Issue airbnb#150
With the release of |
i am still experiencing this on 0.1.35. i'm using typescript 4.8.4 and react 18.2.0. could it be platform-dependent? i'm on linux, and my colleague on mac doesn't experience this issue. |
I was using Ubuntu via WSL with typscript 4.8.4. Are you seeing the miss formatted comments right before closing tags or in other locations? |
here's a screenshot. it's the git diff view: grey = before running script, green = after running script. |
You may want to see verify the package lock file between you and your coworker to make sure you both using the exact same versions. I did a quick test of |
For me, It worked with v4.7.2 which is the same version defined in package.json of ts-migrate repo. |
This is broken with typescript 4.9.5, but not when I downgrade to 4.7.2. |
I'm getting comments inside the (t|j)sx expressions with TypeScript Thanks @jcurtis |
Downgrade to typescript@4.7.2 saves me. 🙏 |
I'm giving ts-migrate a try to migrate a large gatsby project. My issue is JS comments are inserted in components:
This makes them visible in the rendered output. They should be inserted with braces instead:
I ran
npx -p ts-migrate -c "ts-migrate-full ."
at the root of the project. During the migration I saw a lot of occurrences of this error:I have 108 .tsx files in the project so this will be cumbersome to fix, did I do something wrong during the conversion?
The text was updated successfully, but these errors were encountered: