Babel-eslint: space-infix-ops reports polymorphic functions

Created on 6 Aug 2016  路  7Comments  路  Source: babel/babel-eslint

const a = <T> (): void => {}
1:11  warning  Infix operators must be spaced  space-infix-ops

Follow up of #226

bug

Most helpful comment

The issue still exists when calling any polymorphic functions/method with a given parameter like so:

polyFunction<string>('hi');

This is a bit frustrating, as flowtype is going in a direction of less magic inference (* is deprecated), and sometimes it is now required to give Polymorphic function parameters in complex situations or flow will report an error. (Which is still better than before when it was failing to infer it silently i guess)

const fx = <T: SomeComplexTypeUnion>(t: T) => { ... };

fx('foo'); // flow error: "Missing type annotation for `T`"

fx<string>('foo'); // no flow error, eslint error: "Infix operators must be spaced  space-infix-ops"

eslint: 5.2.0 (latest)
babel-eslint: 8.2.6 (latest)
eslint-plugin-flowtype: 2.50.0 (latest)
flow: 0.79 (latest)

All 7 comments

Could this be related to https://phabricator.babeljs.io/T7330 which was fixed recently, by https://github.com/babel/babylon/pull/54

Given that babel-eslint seems to still be on babylon@^6.0.18 it seems likely to me that update of babylon would fix this.

we use ^ thought so you would just npm install

we use ^ thought so you would just npm install

Oh never mind then, I assumed it was only updating minor version. So I guess there is in fact some issue here.

The issue still blocks development with polymorphic static class method:
CacheClass.parseMethod<T>('some argument')

eslint 3.3.1
babel-eslint 6.1.2
eslint-plugin-flowtype 2.11.4

The issue still exists when calling any polymorphic functions/method with a given parameter like so:

polyFunction<string>('hi');

This is a bit frustrating, as flowtype is going in a direction of less magic inference (* is deprecated), and sometimes it is now required to give Polymorphic function parameters in complex situations or flow will report an error. (Which is still better than before when it was failing to infer it silently i guess)

const fx = <T: SomeComplexTypeUnion>(t: T) => { ... };

fx('foo'); // flow error: "Missing type annotation for `T`"

fx<string>('foo'); // no flow error, eslint error: "Infix operators must be spaced  space-infix-ops"

eslint: 5.2.0 (latest)
babel-eslint: 8.2.6 (latest)
eslint-plugin-flowtype: 2.50.0 (latest)
flow: 0.79 (latest)

Thank you for the issue. Now that @babel/eslint-parser has been released, we are making this repository read-only. If this is a change you would still like to advocate for, please reopen this in the babel/babel monorepo.

Was this page helpful?
0 / 5 - 0 ratings