Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flow-remove-types] Output is corrupted by \u2019 characters #8060

Open
sgb-io opened this issue Sep 3, 2019 · 1 comment
Open

[flow-remove-types] Output is corrupted by \u2019 characters #8060

sgb-io opened this issue Sep 3, 2019 · 1 comment

Comments

@sgb-io
Copy link

sgb-io commented Sep 3, 2019

Flow version: 2.106.3 (flow-remove-types).

Note that I'm not entirely clear how the version of flow-remove-types is coupled to flow.

Expected behavior

Flow syntax is removed.

Actual behavior

Most flow syntax is removed, but at this character, the output gets corrupted.

Example

const flowRemoveTypes = require('flow-remove-types')

const contents = `
// @flow

import React, { Component } from 'react'

export const ComponentA = () => (
  <div>Component that contains a thing’y</div>
)

export const ComponentB = () => (
  <div>Another component that contains a thing’y</div>
)

type Props = {|
  name: 'example'  
|}

class ExampleComponent extends Component<Props> {
  constructor(props: Props) {
    super(props)

    this.state = {
      foo: 'bar',
    }
  }

  render() {
    return (
      <div>Foo</div>
    )
  }
}

export default ExampleComponent
`

const removed = flowRemoveTypes(contents, { pretty: true }).toString()
console.log(removed)

Expected output:

// 

import React, { Component } from 'react'

export const ComponentA = () => (
  <div>Component that contains a thing’y</div>
)

export const ComponentB = () => (
  <div>Another component that contains a thing’y</div>
)


class ExampleComponent extends Component {
  constructor(props) {
    super(props)

    this.state = {
      foo: 'bar',
    }
  }

  render() {
    return (
      <div>Foo</div>
    )
  }
}

export default ExampleComponent

Actual output:

// 

import React, { Component } from 'react'

export const ComponentA = () => (
  <div>Component that contains a thing’y</div>
)

export const ComponentB = () => (
  <div>Another component that contains a thing’y</div>
)

typeass ExampleComponent extends Component<Pro constructor(props: Pr    super(props)

    this.state = {
      foo: 'bar',
    }
  }

  render() {
    return (
      <div>Foo</div>
    )
  }
}

export default ExampleComponent
@sgb-io
Copy link
Author

sgb-io commented Sep 3, 2019

Possibly related to #7779.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants