Skip to content

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

@sgb-io

Description

@sgb-io

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

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