Closed rosswarren closed 3 years ago
Can't we just check for !(parent.type.slice(0,2) === 'TS')
? With your proposed change it fixes that specific error for me, but I get more TS-type related errors after it.
@ChrisGitter I'm concerned that it could stop the plugin from rewiring certain things that could actually be handled? Is it actually safe to ignore everything prefixed with TS
?
@rosswarren I have no idea if it is safe. I'm way too unfamiliar with the babel transpiling process and all the babel types. You're probably right with the assumption that some of the TS
prefixed stuff shouldn't be left out. I'll check if I can reproduce the follow-up errors I got with the TS-related types and post them here.
Will it be merged? Typescript is getting more and more popular now. It would be nice to see a perfectly working Typescript + rewire module
Thanks for posting this pull request!
I had to change to:
!(parent.type === 'TSTypeQuery') &&
!(parent.type === 'TSTypeReference')
to make it work for me.
Thanks!!! I needed to add TSQualifiedName
to the list as well.
Thanks @Machiaweliczny, @philippelesaux I have added both TSTypeQuery
and TSQualifiedName
.
I also needed to exclude TSExpressionWithTypeArguments
and TSDeclareFunction
Any updates on when this could be merged in? We are seeing this issue after moving to typescript. It seems like a quick fix and it should be safe.
Are there any updates on this? I'm also getting the following error when trying to use this plugin with the @babel/typescript
preset:
TypeError: Property left of TSQualifiedName expected node to be of a type ["TSEntityName"] but instead got "CallExpression"
@rosswarren's fix is working for me when I also exclude the types that @NilSet identified (TSExpressionWithTypeArguments
and TSDeclareFunction
)
I also ran into an issue with default exports and function overloads. You can fix it by adding
if (!wasProcessed(path) && !t.isTSDeclareFunction(path.node.declaration)) {
to line 106 of your PR.
Any chance this could have some traction. Makes the plugin useless for TypeScript projects which is specifically what it's good for.
Because this has not been merged, I have published this branch as babel-plugin-rewire-ts version 1.3.0. I will happily accept any contributions there to improve compatibility. https://github.com/rosswarren/babel-plugin-rewire-ts https://www.npmjs.com/package/babel-plugin-rewire-ts
It's June 2020. Are there any updates on this? Why isn't it merged yet?
Fixes: https://github.com/speedskater/babel-plugin-rewire/issues/218
Update: due to this not being merged for a long time I have published a fork as babel-plugin-rewire-ts to unblock myself. You are welcome to use it too. You can contribute any further fixes here https://github.com/rosswarren/babel-plugin-rewire-ts. https://www.npmjs.com/package/babel-plugin-rewire-ts.
I understand you probably want tests for this change, but I have no idea how we can actually do that because the rest of the tests haven't been updated for babel 7 and I can't run
@babel/preset-typescript
against babel 6.