Skip to content

Type spread on imported types doesn't work #230

@konstantinkreft

Description

@konstantinkreft

This is a:

  • Bug Report
  • Feature Request
  • Question
  • Other

Which concerns:

  • flow-runtime
  • babel-plugin-flow-runtime
  • flow-runtime-validators
  • flow-runtime-mobx
  • flow-config-parser
  • The documentation website

What is the current behaviour?

Example:

import type { Bar } from './types';

type Foo = {|
  ...Bar,
  foobar: string,
|};

If a type is imported from external file and spread into another type the following error is thrown: TypeError: Invalid attempt to spread non-iterable instance.

It seems like that at this point the @babel/flow preset already stripped out the types so it tries to spread undefined.

But if both types are declared in the same file everything works fine.

To showcase this bug I created a minimal reproducible example over here: https://github.com/risetechnologies/flow-runtime-bug


What is the expected behaviour?

It should be possible to spread a type from external file into another type.


Which package versions are you using?

flow-runtime: 0.17.0
babel-plugin-flow-runtime: 0.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions