rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.

Home Page:https://rescript-lang.org/docs/gentype/latest/introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flow: unused suppression comment warnings

TomiS opened this issue · comments

I'm getting very easily unused suppression comment warnings when using genType with the existing flow setup

The warnings point to generated files to these lines:

// flowlint-next-line nonstrict-import:off

I'm wondering would it help if there would be a flag in genType config that allows disabling lint comments in output.

Or what are the reference lint settings that genType assumes? Are they available somewhere?

We're using in our .flowconfig

[lints]
untyped-type-import=error
nonstrict-import=error

If I remove nonstrict-import=error line, or set any other value to it, flow actually errors with genTyped code.

@TomiS this looks like an in-fight between the type checker, that generally wants you to add things, and the linter, which in this case seems to want you to remove thing based on insider information.

Not sure. Do you have any suggestions?

To be concrete: disabling lint comments will get the type checker to complain in a lot of cases, so it's a non-option.
Trying to couple tightly with the type checker, as the linter does, also sounds like a recipe for trouble, any time a new version of the type checker changes something.

@cristianoc I checked that if I manually remove the lint comments from the .gen.js files, the warnings disappear. So in my case it would be optimal if I could just add a flag to genType config in bsconfig.js that instructs genType to just skip writing the line:

// flowlint-next-line nonstrict-import:off

The flag could be 'off' by default, so it would not be a backwards compatibility break.

@TomiS for that file, yes. For other files, no. It would mean when you change your code, you might get flow errors, not lint warnings, that you can't fix.

If a solution exists, it needs to apply to all files. Not just the result of compilaition for that specific file.
At the moment I can't think of one.

Unless one could also add lint suppression annotations for linter warnings about type checker warning suppression annotations. Tough that is getting paradoxical quickly.

A config stfu=*.bs.js would solve all the issues in one go, if it existed.

@cristianoc Hmm, Sorry if I'm just not "getting it", but these are imports from other gentyped files. So .bs.js are not related, right?. The linting warning is on a line like this:

// flowlint-next-line nonstrict-import:off
import type {foo as My_Types_foo} from '../../.././client-re/src/My_Types.gen';

and on pretty much all other similar imports in other .gen.js files. So my thought is that removing all of those lint comments from all of my gentyped files with a global flag would solve the problem. I don't quite understand how removing the lint comment would cause errors if the warning only happens in imports between gentyped files that are all strict.

@TomiS suppressing only those cases should work. Thanks for the suggestion!
Is that enough to handle your issues?

@cristianoc Possibly/likely. Naturally need to test more (and I'm happy to test if there is a patch), but it would seem promising enough to at least try, imho.

Checked on a certain large project, and looks fine.

Now in master.
If if does not solve all the issues, feel free to re-open.
Otherwise, lmk if a new release would be useful.

Great. Thanks. A release would of course be handy if it's not too much trouble.

Release 3.19.0 being created.

Confirming the new release solved my problem. Thanks again!