Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6211

Are there scripts or tools to help to migrate Flow to TypeScript automatically?

$
0
0

I have an old react-native module using Flow. There are several thousand lines of code. Now, I would like to migrate these codes to a new project using TypeScript. I am looking for an auto-tool to help me solve tedious type-converting works. If it would solve about 90% of problems, I would appreciate it. For example,

  • Changing all the .js file to 'ts or tsx file, like:
for f in `find . -type f -name '*.js'`;
do
git mv -- "$f""${f%.js}.ts"
done
  • convert types
// Flow
import type { Type1, Type2 } from ./dir/to/path
// Typescript
import { Type1, Type2 } from ./dir/to/path
// Flow
type Date = {
  toString: () => string,
  setTime: (time: number) => number
}

// TypeScript
interface Date {
  toString(): string;
  setTime(time: number): number;
}

// Flow 
value: ?string 
// TypeScript 
value: string | null

Any suggestions?


Viewing all articles
Browse latest Browse all 6211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>