Skip to content

Support incremental transition from flow to typescript #8762

Description

@penx

Is your proposal related to a problem?

If you have a codebase written in Flow but want to transition to TypeScript, it would be useful for Create React App to support doing this incrementally without additional config.

At the moment, when following the 'Adding Flow' instructions followed by the 'Adding TypeScript' instructions instructions, you get an error such as:

'import type' declarations can only be used in TypeScript files.  TS8006

    1 | // @flow
    2 | import React from 'react';
  > 3 | import type { Node } from 'react';

Example steps to recreate in the first 3 commits here:

https://github.com/penx/cra-flow-ts/commits/master

Describe the solution you'd like

If you follow the 'Adding TypeScript' instructions and add TypeScript to a project that already uses Flow, it should compile both Flow and TypeScript files correctly.

Describe alternatives you've considered

This is possible by manually editing .tsconfig after it is generated, as per @tebuevd's comment below. However, Create React App should detect the presence of flow (either flow-bin being in dependencies or presence of a .flowconfig file) and setup .tsconfig to have "include": ["src/**/*.ts", "src/**/*.tsx"] and "allowJs": false when it is generated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions