Skip to content
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

--outDir and keeping source #19

Open
AaronNGray opened this issue May 22, 2020 · 5 comments
Open

--outDir and keeping source #19

AaronNGray opened this issue May 22, 2020 · 5 comments

Comments

@AaronNGray
Copy link

I am doing a conversion from Flow to TypeScript when I am modifying the Flow source in order to get the TypeScript to compile properly without errors with tsc. So want to keep the source and have the TypeScript output in another directory tree, so need TypeScript like --outDIr.

e.g. to translate from src to ts :-

flowts --outDir ts src
@zxbodya
Copy link
Owner

zxbodya commented May 22, 2020

I would advise against doing so… it is much less work to just convert it, and to fix type errors.

If code was converted from flow to typescript using flows, without errors - it is guaranteed to be exactly the same after stripping the type information (there is a verification step which literally checks for this, if the check is failing - original .js file would not be removed, and error would be printed to the log).

After converting while tsc type check is likely to fail, code would be totally ok to compile with babel (just replace flow preset with typescript, and it is good to go)

Also, if starting with not strict typescript configuration - there are not too many manual fixes needed

if you want to do migration gradually while continuing to work with flow version - it is still better to convert everything, and periodically rebase typescript version on master(this way it is much harder to get out of sync, and it is not too much work to do so - just rerun flowts, and interactively rebase the fixes)

I am doing it in a few big projects, for example in opensource:

(both are still work in progress and periodically are rebased)

@AaronNGray
Copy link
Author

AaronNGray commented May 22, 2020

I cannot maintain alignment between the sources which I need to do. And will have to fork flowts or your babel-plugin-flow-to-typescript and use my existing babel superstructure otherwise.

@zxbodya
Copy link
Owner

zxbodya commented May 22, 2020

Can you provide a bit more details about your use case?

I do not really understand the use case for this, still thinking it is better to just convert it in place in a branch - and so, would like to avoid adding new CLI argument, if possible.


btw,

another quick and dirty option, if you really need a copy of code converted to typescript - you can just copy flow sources to the destination place and to convert it there

also, about babel-plugin-flow-to-typescript - if you need just it, you can use it directly - the version from flowts repository - is published on npm as @zxbodya/babel-plugin-flow-to-typescript

@AaronNGray
Copy link
Author

I am converting a very large code base from Flow to TypeScript then to C++. I need to have continuity with the original Flow code, so I can give mods in Flow back to the original code base and have continuity in the conversion pipeline. Then I need to be able to keep alignment with the original Flow source code.

@AaronNGray
Copy link
Author

Okay I have got my babel code working with @zxbodya/babel-plugin-flow-to-typescript.

Many thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants