Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor + flowtype

I was playing around with all tools/technics I know to try to make Meteor and Flowtype to be friends. I made a meteor package to run flowtype checker as a linter. It works, but brings more troubles than help to my project so far. The problem is that flow does not have an easy way to declare all global libs interfaces, so when it checks my code, it of cause does not know anything about Meteor or Session global variables. Do I have to convert all Meteor API to an interface for Flow? It also has troubles to understand the way we use to define global vars in Meteor. enter image description here

Have anybody tried to fix this issues and how?

like image 554
ZuzEL Avatar asked Oct 19 '22 18:10

ZuzEL


1 Answers

What you need is an interface file.

You need to do the following:

Declare the .flowconfig file (it's automatically created when you run flow init).

Create a folder to store your interface files that is ignored by Meteor so it doesn't try to parse it. Meteor ignores certain folder patterns, so you could try mkdir .interfaces. Add the folder to the [libs] section of your .flowconfig, comme ça:

[libs]
.interfaces/

Inside, you can create declarations for your global modules. To create one for Meteor, you can try to touch .interfaces/meteor.js and write something along these lines:

declare class Meteor {
  isClient: boolean;
}

Let me know if that works. Still learning flowtype myself.

like image 145
Theodor Vararu Avatar answered Nov 02 '22 11:11

Theodor Vararu