flowts
flowts copied to clipboard
--outDir and keeping source
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
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)
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.
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
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.
Okay I have got my babel code working with @zxbodya/babel-plugin-flow-to-typescript.
Many thanks !