Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cometkim/mattermost-typed

⛔ DEPRECATED ⛔ Flow type definition library for Mattermost
https://github.com/cometkim/mattermost-typed

flow libdefs mattermost

Last synced: about 2 months ago
JSON representation

⛔ DEPRECATED ⛔ Flow type definition library for Mattermost

Awesome Lists containing this project

README

        

⛔ DEPRECATED ⛔

This library has been deprecated by https://github.com/cometkim/mattermost-typed/issues/18

But [mattermost-redux](htttps://github.com/mattermost/mattermost-redux) is starting to support flowtype! Please consider to contribute types to the Mattermost codebase.

# Mattermost type definitions
[Flow](https://flow.org/) type definition library for [Mattermost](https://about.mattermost.com/)

Compatible with [Mattermost API](https://api.mattermost.com) and [Mattermost Redux](https://github.com/mattermost/mattermost-redux)

This project will help you in your Mattermost projects:
* Understanding Mattermost codebase.
* Preventing building bad request or parsing response incorrectly.
* Improves productivity with intelligence support.

## Install

Install
```sh
yarn add --dev mattermost-typed
npx flow init # initialize flow if you've not.
```

Add a line under libs tag on your `.flowconfig`
```diff
[libs]
+./node_modules/mattermost-typed/
```

Add the preset (if you use BabelJS)
```sh
yarn add --dev babel-preset-flow
```

`.babelrc`
```diff
preset: [
+ "flow"
]
```

## How to use

### By CLI
```
npx flow [COMMAND]
```

or add script into your `package.json`
```diff
scripts: {
+ "flow": "flow"
}
```

### VSCode Extentions
* [Flow Language Support](https://marketplace.visualstudio.com/items?itemName=flowtype.flow-for-vscode)

## Why?
You might wonder if this is really necessary.
Well, Here is why I came to think it is - Expect the type of Get Posts API.

I was building a Mattermost integration and I expected it would of course be an array of Post.
And I had to see the result of `map is not a function` because of the result of the Get Posts API that looks like:
```json
{
"order": [
"post_id1",
"post_id2"
],
"posts": {
"post1": {},
"post2": {}
}
}
```

* It was your fault. Mattermost have documentation for it.
* Why did you not write test, evil.

You can think it is wrong not to check the documentation or write test code. But generally it could be skip when productivity is important like in prototyping.
type checking is simple and a great solution to avoid mistakes.

* PropTypes is not enough?

PropTypes is great sollution to assert types. But it's only for React component.

## Typescript?
TODO