facebookarchive / ide-flowtype

Flow support for Atom IDE
Other
178 stars 17 forks source link

Support JSX for React.js projects #33

Closed pesterev closed 6 years ago

pesterev commented 6 years ago

Is it planned to support JSX React.js projects and how can i help?

Cerberus commented 6 years ago

It's already support React Component.

If you write a stateful component, the code is look like this

class Test extends React.Component<Props> {

Stateless component with enhance Function can be written like this

import { type HOC, compose, lifecycle, mapProps, pure } from 'recompose'
import React from 'react'

type Common = {
    className?: string,
}

type Enhanced = {
    a: boolean,
    b: boolean,
    show: boolean,
} & Common

type Props = {} & Common

const enhance: HOC<Props, Enhanced> = compose(
    lifecycle({}),
    mapProps(({ ...rest }) => ({ ...rest })),
    pure,
)

export const Test = ({ className }: Props) => (
    <div className={className}>
        <span />
    </div>
)

export default enhance(Test)

Type checking work normally like other packages.

To make autocomplete, you need to type at least 3 characters to active hint tooltip. (Custom Minimum word length on autocomplete-plus core package)

auto

Shall we close this? 😄

pesterev commented 6 years ago

Yes, now the current version supports jsx. Thnx