Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Error: no-for-in-array requires type checking #1445

Closed
Delagen opened this issue Jul 29, 2016 · 18 comments
Closed

Error: no-for-in-array requires type checking #1445

Delagen opened this issue Jul 29, 2016 · 18 comments

Comments

@Delagen
Copy link

Delagen commented Jul 29, 2016

Bug Report

  • TSLint version: 3.14.0
  • TypeScript version: 2.0.0
  • Running TSLint via: Node.js API

TypeScript code being linted

with tslint.json configuration:

{
    "linterOptions": {
        "typeCheck": true
    },
    "rules": {
        "no-for-in-array": true
    }
}

Actual behavior

Error: no-for-in-array requires type checking
at Rule.TypedRule.apply (...\node_modules\tslint\lib\language\rule\typedRule.js:14:15)
at Linter.lint (...\node_modules\tslint\lib\tslint.js:65:37)
...

Expected behavior

No errors

@adidahiya
Copy link
Contributor

linterOptions in tslint.json is actually a private API. If using the CLI, you must use the --type-check flag. If using the Node.js APIs, you'll need to follow a pattern similar to src/test.ts.

@Delagen
Copy link
Author

Delagen commented Jul 31, 2016

This is ugly and must be public

@adidahiya
Copy link
Contributor

Well, it's not a documented API... how did you discover it? We reserve the right to experiment with APIs in our project before committing to them...

@Delagen
Copy link
Author

Delagen commented Aug 1, 2016

Reading code of sample configurations, and reading code is the best documentation in most javascript projects. Developers update documentation very slow, released features may be documented after long time, some projects does not provide documentation about Node API use totally prefer to offer only CLI use, that is ugly.

@Delagen
Copy link
Author

Delagen commented Aug 2, 2016

Many build tools plugins use Node.JS api, and it's functionality must not differ from CLI, because CLI does not provide ability to control process of output etc.
For example: https://github.com/panuhorsmalahti/gulp-tslint/blob/master/index.js

@adidahiya
Copy link
Contributor

reading code is the best documentation in most javascript projects

Sure, that's partially true -- that's why I pointed out src/test.ts in my comment above.


I agree that the Node.js API is useful and should be documented. We do have documentation for parts that are well-supported, including type checking, right here in the README. Also, being a typescript project, we naturally have documentation in the form of typings declaration files published in the NPM package.

Sure, the GH pages site is a little behind compared to the README -- we're working on improving that. But I might suggest a slightly different tone for your form of contribution here -- you will probably experience more success by, say, sending a documentation PR before calling a project "ugly".

@jkillian
Copy link
Contributor

jkillian commented Aug 7, 2016

The GH pages site is now updated with the latest rule metadata from the most recent release. (I realize this is a little tangential to the issue at hand though.)

Currently, tslint.json files only specify how individual files should be linted and do not specify overarching linter options. Allowing tslint.json files to specify overarching options is a bit of a paradigm change, and that's why we're experimenting with some new setups internally before changing any public-facing API.

@JoshuaKGoldberg
Copy link
Contributor

Just ran into that error after attempting to enable no-for-in-array in a tslint.json, and this GH issue was the only Google result that popped up. Can the error message at least point to documentation?

As a side note, is there documentation on enabling it for the Gulp runner?

@jkillian
Copy link
Contributor

Not sure with regards to the Gulp runner. We need to update the docs site to make it more clear which rules require typechecking and what that means

@StevenDoesStuffs
Copy link

Can u plz tell me how would I deal with this issue on an IDE like webstorm?

@StevenDoesStuffs
Copy link

Could you plz make linterOptions typecheck public or something?

@StevenDoesStuffs
Copy link

Actually, I think making type checking a rule would be more useful and accessible.

@StevenDoesStuffs
Copy link

Any updates?

@adidahiya
Copy link
Contributor

@StevenTheEVILZ just disable the rule in your tslint.json. The Webstorm plugin needs to be updated to support the new type checking APIs -- that's external to this repo. This needs to happen regardless of linterOptions in tslint.json being public (I assume they're using the Node.js APIs, not the CLI, in the plugin).

@StevenDoesStuffs
Copy link

StevenDoesStuffs commented Sep 19, 2016

@adidahiya I've already fixed the problem by using the tslint js lib. BTW they are using the cli and capturing its output.

@timocov
Copy link
Contributor

timocov commented Jan 16, 2017

@adidahiya What is the point that you do not make this API public?
I guess it will be very useful to set all TSLint settings via tslint.json.

@codeaid
Copy link

codeaid commented Sep 8, 2017

I'm using create-react-app with react-scripts-ts and keep getting Warning: The 'no-use-before-declare' rule requires type information. because there's no way for me to specify command line parameters. I don't really understand what is the reasoning for not being able to specify all options in tslint.json.

@JoshuaKGoldberg
Copy link
Contributor

As of #3322, typeCheck has been deprecated. Closing this issue for housekeeping.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants