flowtype


Why is Flow losing precision when I move to ES6 class syntax?


I am using Flow to infer the types of the following code:
function Point (x, y) {
this.x = x;
this.y = y;
}
Point.prototype.print = function (msg) {
console.log(msg);
}
function Line ()
{
this.p1 = new Point(2,3);
this.p2 = new Point(3,1);
}
Line.prototype.testLine = function () {
return this.p1.print('Test Point');
}
// Testing
var l = new Line();
l.testLine();
Flow correctly infers that the type of the parameter msg (line 5) is 'string'. However, when I migrate classes Point and Line to ES6 syntax (see code below), Flow indicates that the type of msg is 'empty', losing the information about the correct type.
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
print(msg) {
console.log(msg);
}
}
class Line {
constructor() {
this.p1 = new Point(2,3);
this.p2 = new Point(3,1);
}
testLine() {
return this.p1.print('Test Point');
}
}
// Testing
var l = new Line();
l.testLine();
In this case, why is Flow losing precision when I move to ES6 class syntax? How can I fix this?
I am currently using Flow version 0.44.1
The command I execute to get the type information is:
flow dump-types --strip-root Line.js > Line.dump

Related Links

how to declare modules that has other modules in Flowtype?
How should a disjoint union wrapper be structured for refinement to work?
how to specify a range of folders in ignore section of Flowtype .flowconfig?
Filtering out maybe types before accessing nullable property
flowtype - higher order functions - currying
Flowtype: array of possible strings cannot be empty?
Defining an object consisting of other object types in Flow
Idiomatic way to access properties of union type
how to set the status of err to avoid flowtype check warning?
How can I get inferred type data with flowtype command?
Flow bool, boolean and Boolean
how to reuse object type definition in class definition in flowtype
flow fails on union type even with if/else
Strange error message “inconsistent use of library definitions” in flowjs
Declare a function using a type alias
Setup flow to typecheck just *my* types

Categories

HOME
qlikview
logging
indexing
grizzly
ftp
gsm
ssh
pelican
casting
django-middleware
where
jshell
liquidsoap
vsixmanifest
google-app-maker
drush
saucelabs
infopath
nsoperation
amazon-data-pipeline
gpo
scotty
computation-theory
git-branch
coccinelle
rndis
opengraph
pushbullet
mongoose-im
checkmarx
folder
deferred
language-detection
ng2-bootstrap
epub
android-geofence
aweber
hippocms
armadillo
sknode
paperclip
text-extraction
spring-webflow-2
spring-ide
mef
automapper-4
jenkins-docker
openpgp.js
tsc
was
suitesparse
stripes
cedar-bdd
alfred
netlink
recurring
innertext
abstract
imageicon
pagecontrol
callfire
vspackage
httpmodule
parseexception
wingdb
nsmutableurlrequest
azure-worker-roles
connections
thucydides
fade
infomaker
ojb
azure-pack
maven-webstart-plugin
uikit-dynamics
symbian3
spawn
database-restore
gpl
freeimage
tasklist
report-viewer2010
beep
github-archive
nude.js
nsundomanager
utm
openwrap
method-call
quazip
chars
webdb

Resources

Encrypt Message