Skip to content

Can't use named exports for TypeScript types? #6570

Closed
@zaynv

Description

@zaynv

Is this a bug report?

Yes

Did you try recovering your dependencies?

Not relevant.

Which terms did you search for in User Guide?

TypeScript

Environment

System:
OS: macOS 10.14.2
CPU: x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Binaries:
Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
Yarn: 1.5.1 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
Browsers:
Chrome: 72.0.3626.119
Firefox: 65.0
Safari: 12.0.2
npmPackages:
react: ^16.8.3 => 16.8.3
react-dom: ^16.8.3 => 16.8.3
react-scripts: 2.1.5 => 2.1.5
npmGlobalPackages:
create-react-app: 2.1.5

Steps to Reproduce

  1. create-react-app --typescript example
  2. Create a file in src called types.ts
  3. Add the following code to types.ts:
interface Person {
  name: string
  age: number
}

export { Person }

Expected Behavior

This should be fine.

Actual Behavior

Failed to compile.

/Users/zaynv/Projects/misc/example/src/types.ts
Type error: Cannot re-export a type when the '--isolatedModules' flag is provided.  TS1205

    4 | }
    5 |
  > 6 | export { Person }
      |          ^
    7 |

I can't remove the --isolatedModules flag because create-react-app seems to put it back in automatically when it compiles. Is there really no way to fix this issue other than having to use export interface X and export interface Y everywhere instead of export { X, Y }?

Reproducible Demo

I can make one if necessary, but its basically just a new app with an exported type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions