ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.97k stars 3.25k forks source link

Flow #2001

Closed steida closed 6 years ago

steida commented 6 years ago

Is there any plan to leverage https://flow.org? It's pretty stable and nice and all, and it would be great to have autocomplete etc.

How can I help?

steida commented 6 years ago

So I tried to add Flow to project https://github.com/steida/slate/commit/8139ea3f71f302d508dd91e662f7189af4ed688e

Realizing there are no straightforward docs for Workspaces with Flow. Naive approach works, except importing from another package which can be ignored for now.

// @flow
// $FlowFixMe Flow can't resolve import.
import logger from 'slate-dev-logger'

Flow can be added gradually, file by file. I can help with question, but I am not understanding Slate enough to full type it.

twavv commented 6 years ago

Some people have worked on TypeScript declaration files. I know there's at least one tool online that can convert (though it might have a few issues), or you could use the TypeScript as "inspiration" as it were.

zhujinxuan commented 6 years ago

I tried flow with slateJS/ImmutableJS. The unfortunate thing is it is very hard to support extends Records and super-classes. I am trying to switch my plugins from flow to typescript currently.

steida commented 6 years ago

@zhujinxuan Have you seen ImmutableJS 4? Much better.

zhujinxuan commented 6 years ago

@steida I tried, but there is still no way to support extends Record({...})

class Block extends Record({defaultProps}) {
    someUserFunctions() {
    }
}

that

Block.set(string, value) => Block
Block.merge(...) => Block
ianstormtaylor commented 6 years ago

Hey folks, check the other issues about typings that have been opened in the past. If I was to ever choose to adding typings to Slate I would almost certainly using TypeScript instead of Flow, but at this exact moment I have no plans of incorporating either.