-
-
Notifications
You must be signed in to change notification settings - Fork 208
Conversation
@@ -187,10 +187,6 @@ var astTransformVisitor = { | |||
return node.expression; | |||
} | |||
|
|||
if (t.isFlow(node)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So then we need to remove this line? #89 (comment)
This should do the trick. At least for very simple cases, although you can have deeply nested type annotations that this wont cover. |
So then we would need to do the same for say variable declaration type, parameter return type, etc? Yeah I guess cover the common cases? // fails at the moment
it("flow type var declaration", function () {
verifyAndAssertMessages([
"import type Foo from 'foo';",
"var x: Foo = 1;",
"x;"
].join("\n"),
{ "no-unused-vars": 1 },
[]
);
}); |
|
Ok this is kind of crazy - didn't cover everything but yeah. Are there any github projects using flow to test this stuff on? |
@hzoo: I'll ask in the internal Flow group at FB to see if anybody has any good open source examples. |
Somebody suggested the React Native example apps (eg. https://github.com/facebook/react-native/tree/master/Examples/2048 etc). |
Ok cool I'l check it out - nice that it already has a |
Maybe we should just push a simple change (already done in this PR) to fix just the |
1e88544
to
c89a0e9
Compare
Ok rewrote most of it since there were a lot of random issues. Should of got most of the types in To fix still: #66 again because // have to visit TypeAlias?
// no-undef ExampleClass
type ExampleClass = {
Component: ReactClass<any, any, any>,
title: string,
description: string,
};
var exampleClasses: Array<ExampleClass> = []; Seems like you either get
Should we be removing the declares? Then you would add all variables to globals in if (t.isDeclareModule(node)) {
return this.remove();
} Ok removing the declares. |
bfb5ae5
to
5e94b81
Compare
Ok so I guess we want From https://github.com/estools/escope/blob/master/src/variable.js#L72-L79 I found different variable types so I'm just using And then found out you can just do Still need to add all the tests as well as visit the It looks like there is use of |
@hzoo Nope. The |
Ok I guess there's just a lot of types that aren't imported explicitly in each file itself like Examples of // $Enum
{
property: $Enum<typeof Properties>;
}
// mixed
_search(text: mixed) {
// D, P, S
function renderApplication<D, P, S>(
RootComponent: ReactClass<D, P, S>,
initialProps: P,
rootTag: any
) {
// T
getNode: function<T>(id: T): T {
return id;
} |
I'm just going to add tests for everything next - do you think I need add/change anything at the moment @sebmck? |
Doesn't look too bad. Only comment would be on the use of |
Yeah ok, I should replace all those will just regular for loops. Maybe the code would be better by refactoring it to use the |
Ok refactored the |
@hzoo Looks nicer to me, easier to add additional types later too. |
Ok I'l go ahead and use that then. Is there a way to use |
I guess you could loop over and filter them. |
33c7b58
to
00f0b76
Compare
Yeah don't know if it's that great var visitorKeysMap = pick(t.VISITOR_KEYS, function(k) {
return t.FLIPPED_ALIAS_KEYS.Flow.concat([
"ArrayPattern",
"ClassDeclaration",
"ClassExpression",
"FunctionDeclaration",
"FunctionExpression",
"Identifier",
"ObjectPattern",
"RestElement"
]).indexOf(k) === -1;
});
// don't check "id" to prevent "no-undef" for 'Component' with: 'let x: React.Component'
visitorKeysMap.QualifiedTypeIdentifier = ["qualification"]; |
I added For "ReactClass": false,
"ReactElement": false Not sure about function renderApplication<D, P, S>(
RootComponent: ReactClass<D, P, S>,
... I don't know if those are built-ins/temps for flow or something but it will also create an error (intended). |
Unsure if they all needed to be added, just do whatever you feel comfortable with. Also, it might be best to reuse as much as you can from |
Ok I can add back something like the previous comment #109 (comment)? |
Sure, something like that would work. |
Ok added I think I'm ready to merge other than my confusion of if we need to do anything about |
Seems fine to me. If this is actually an issue then it should be fixed by parsing it as a |
Ok makes sense... so good to merge then? And would this still be a patch version? |
Looks GTM to me. Doesn't really matter what version it's released as since it's not breaking or "adding features" really. |
Hi, I tried the 3.1.10, it seems that it will got no-undef on polymorphic functions.
the code above will got three no-undef errors:
|
I didn't figure out how to get polymorphic functions to work yet (stuff like |
Could bable-eslint remove this |
The previous versions removed all flow types entirely but then you would get Since they aren't going to refer to any types ( } else if (node.type === "Identifier") {
// check if a polymorphic type: <T>, <A>, etc
if (node.name.length === 1 && node.name === node.name.toUpperCase()) {
return;
}
this.visit(node);
} Could do a similar thing for |
add flow exceptions for polymorphic types (<A>) - Ref #109
Ok @Tsing see if 3.1.11 fixes things for you. |
@hzoo Thanks, it works well! |
visit flow types - fixes babel/babel-eslint#108
add flow exceptions for polymorphic types (<A>) - Ref babel/babel-eslint#109
#108