-
Notifications
You must be signed in to change notification settings - Fork 482
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
Support for type casting/predicates on Typescript transform files? #467
Comments
I'm also experiencing the same issue. |
Ran into this issue today as well while trying to create an object lookup based on the value returned from a |
Would you be able to up to github a temporary repository that reproduces the error? |
Of course. Give me a day or two to wrap some things up and I'll get back to you with a link. |
Sorry for the delay, I'm a bit stumped. I created an example project but I can't reproduce the error. As far as I can tell the example is configured exactly the same as my current project that I encountered the issue, but at this point I have to assume it's a configuration problem on my end and not an issue with jscodeshift. If anyone else wants to dig into it, here's my example repo. https://github.com/jimmynotjim/JSCodeshift-type-casting-error This is exactly where the issue exists in my current project but runs just fine in the example: |
I was able to figure out the issue. In my haste to limit the reproduction repo I didn't match my current repo file organization 1:1. In my current repo, I co-locate the transform, tests, and fixtures in a directory with the transform name, and export the transformer via an index file. When running the transform, I've been utilizing node's behavior of mapping the directory name to the index file. It looks something like this
I've updated my reproduction repo to match my current repo's file organization. So now: this throws an error: but this works: I'm unfortunately not experienced enough to understand the difference here. Is there a way to keep the shorter path to the directory or is the full file path a requirement in this situation? |
jscodeshift version: 0.13.0
node version: 16.13.0
command:
npx jscodeshift -t src/transforms/sort-imports --extensions=ts,tsx --parser=tsx "${TRANSFORM_FILE}.ts" --print --dry
I'm using Typescript in a project running jscodeshift and I get the following error when I try to run one of my transform files:
I've gotten a similar errors in the same project while trying to use type casting:
Is there a way to support these features of Typescript being used on the transform files or is there a way to override the parser for the transform script itself and not just the transform target? The
tsx
parser on the target files works great and tests will actually run the same transforms without any problems, but it's an issue if I try to use the codemod for anything other than a test.The text was updated successfully, but these errors were encountered: