facebook / facebook/flow

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

Open
#8,060 1 comment 0 reactions 0 assignees View on GitHub
bug remove-types
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

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

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

const contents = `
// @flow

import React, { Component } from 'react'

export const ComponentA = () => (

Component that contains a thing’y

)

export const ComponentB = () => (

Another component that contains a thing’y

)

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

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

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

render() {
return (

Foo

)
}
}

export default ExampleComponent
`

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

Expected output:

```javascript
//

import React, { Component } from 'react'

export const ComponentA = () => (

Component that contains a thing’y

)

export const ComponentB = () => (

Another component that contains a thing’y

)

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

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

render() {
return (

Foo

)
}
}

export default ExampleComponent
```

Actual output:

```javascript
//

import React, { Component } from 'react'

export const ComponentA = () => (

Component that contains a thing’y

)

export const ComponentB = () => (

Another component that contains a thing’y

)

typeass ExampleComponent extends ComponentFoo
)
}
}

export default ExampleComponent
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.