Skip to content

Flow Type Error with Next.js 6 #4614

@bryanterrell

Description

@bryanterrell

Bug report

Describe the bug

When components with flow types are used the pages using those components throw an "Unexpected token" error due to type.

Packages:

  • babel/preset-flow
  • flow-bin

.babelrc

  • babel/preset-flow in in presets
  • babel/plugin-transform-flow-strip-types in plugins.

To Reproduce

  1. git clone git@github.com:bryanterrell/hello-next-flow.git
  2. cd hello-next-flow
  3. npm i
  4. npm run dev
  5. Open http://localhost:3000 in browser & click Go to About Page
  6. Error is produced:
Syntax Error: Unexpected token, expected ";" (3:5)

  1 | import * as React from "react";
  2 |
> 3 | type Props = {
    |      ^
  4 |   foo: number,
  5 |   bar?: string
  6 | };

Expected behavior

Flow types should be stripped out so component / page can be rendered.

System information

  • OS: macOS
  • Next.js version: 6.0.3

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