Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-undef: false flag on typeof argument types #18

Closed
JamesHenry opened this issue Jan 15, 2019 · 1 comment · Fixed by #244
Closed

no-undef: false flag on typeof argument types #18

JamesHenry opened this issue Jan 15, 2019 · 1 comment · Fixed by #244
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@JamesHenry
Copy link
Member

This issue was initially reported here: eslint/typescript-eslint-parser#557


What version of TypeScript are you using?
3.1.6

What version of typescript-eslint-parser are you using?
21.0.1

What code were you trying to parse?

interface IteratorCallback<Subject, Key, Value> {
	(this: Subject, value: Value, key: Key, subject: Subject): void | false
}
function eachr<Value>(subject: Array<Value>, callback: IteratorCallback<typeof subject, number, Value>): typeof subject;
function eachr<Key, Value>(subject: Map<Key, Value>, callback: IteratorCallback<typeof subject, Key, Value>): typeof subject;
function eachr<Object extends object, Key extends keyof Object>(subject: Object, callback: IteratorCallback<Object, Key, Object[Key]>): Object;
function eachr<Object extends object, Key, Value> (subject: Object | Array<Value> | Map<Key, Value>, callback: IteratorCallback<typeof subject, Key, Value>): typeof subject {
	return subject
}

export default eachr

What did you expect to happen?
Just get back:

  7:102  warning  'callback' is defined but never used  no-unused-vars

What happened?

Got back no-undef errors:

  4:80   error    'subject' is not defined              no-undef
  4:113  error    'subject' is not defined              no-undef
  5:88   error    'subject' is not defined              no-undef
  5:118  error    'subject' is not defined              no-undef
  7:102  warning  'callback' is defined but never used  no-unused-vars

Here is the .eslintrc:

{ extends: [ 'eslint:recommended' ],
  plugins: [ 'typescript', 'babel' ],
  parserOptions:
   { ecmaFeatures: { jsx: false },
     sourceType: 'module',
     ecmaVersion: 5 },
  env:
   { es6: false,
     node: true,
     browser: true,
     commonjs: true,
     'shared-node-browser': true },
  rules:
   { 'no-cond-assign': [ 2, 'always' ],
     'no-console': 1,
     'no-constant-condition': 1,
     'no-control-regex': 2,
     'no-debugger': 1,
     'no-dupe-args': 2,
     'no-dupe-keys': 2,
     'no-duplicate-case': 2,
     'no-empty': 0,
     'no-empty-character-class': 2,
     'no-ex-assign': 2,
     'no-extra-boolean-cast': 2,
     'no-extra-parens': 0,
     'no-extra-semi': 2,
     'no-func-assign': 2,
     'no-inner-declarations': 2,
     'no-invalid-regexp': 2,
     'no-irregular-whitespace': 2,
     'no-obj-calls': 2,
     'no-prototype-builtins': 0,
     'no-regex-spaces': 2,
     'no-sparse-arrays': 2,
     'no-template-curly-in-string': 1,
     'no-unexpected-multiline': 2,
     'no-unreachable': 2,
     'no-unsafe-finally': 2,
     'no-unsafe-negation': 2,
     'use-isnan': 2,
     'valid-jsdoc':
      [ 2,
        { requireParamDescription: false,
          requireReturnDescription: false } ],
     'valid-typeof': 2,
     'accessor-pairs': 0,
     'array-callback-return': 2,
     'block-scoped-var': 0,
     'class-methods-use-this': 1,
     complexity: 0,
     'consistent-return': 0,
     curly: [ 2, 'multi-line' ],
     'default-case': 2,
     'dot-location': [ 2, 'property' ],
     'dot-notation': 2,
     eqeqeq: [ 2, 'allow-null' ],
     'guard-for-in': 2,
     'no-alert': 1,
     'no-caller': 2,
     'no-case-declarations': 2,
     'no-div-regex': 2,
     'no-else-return': 0,
     'no-empty-function': 0,
     'no-empty-pattern': 2,
     'no-eq-null': 0,
     'no-eval': 2,
     'no-extend-native': 2,
     'no-extra-bind': 2,
     'no-extra-label': 2,
     'no-fallthrough': 2,
     'no-floating-decimal': 2,
     'no-global-assign': 2,
     'no-implicit-coercion': 2,
     'no-implicit-globals': 2,
     'no-implied-eval': 2,
     'no-invalid-this': 0,
     'no-iterator': 2,
     'no-labels': 2,
     'no-lone-blocks': 2,
     'no-loop-func': 2,
     'no-magic-numbers': 0,
     'no-multi-spaces': 0,
     'no-multi-str': 2,
     'no-new-func': 2,
     'no-new-wrappers': 2,
     'no-new': 2,
     'no-octal-escape': 2,
     'no-octal': 2,
     'no-param-reassign': 0,
     'no-proto': 2,
     'no-redeclare': 2,
     'no-restricted-properties': 0,
     'no-return-assign': 2,
     'no-script-url': 2,
     'no-self-assign': 2,
     'no-self-compare': 2,
     'no-sequences': 2,
     'no-throw-literal': 2,
     'no-unmodified-loop-condition': 1,
     'no-unused-expressions': 2,
     'no-unused-labels': 2,
     'no-useless-call': 2,
     'no-useless-concat': 2,
     'no-useless-escape': 2,
     'no-void': 2,
     'no-warning-comments': [ 1, { terms: [ 'todo', 'fixme' ], location: 'anywhere' } ],
     'no-with': 2,
     radix: 2,
     'vars-on-top': 0,
     'wrap-iife': 2,
     yoda: [ 2, 'never' ],
     strict: [ 2, 'global' ],
     'init-declarations': 0,
     'no-catch-shadow': 0,
     'no-delete-var': 2,
     'no-label-var': 2,
     'no-restricted-globals': 0,
     'no-shadow-restricted-names': 2,
     'no-shadow': 0,
     'no-undef-init': 2,
     'no-undef': 2,
     'no-undefined': 2,
     'no-unused-vars': 1,
     'no-use-before-define': 2,
     'callback-return': 0,
     'global-require': 0,
     'handle-callback-err': 2,
     'no-mixed-requires': 2,
     'no-new-require': 2,
     'no-path-concat': 2,
     'no-process-env': 0,
     'no-process-exit': 0,
     'no-restricted-modules': 0,
     'no-sync': 1,
     'array-bracket-spacing': [ 2, 'never' ],
     'block-spacing': [ 2, 'always' ],
     'brace-style': [ 2, 'stroustrup', { allowSingleLine: true } ],
     camelcase: 2,
     'comma-dangle': [ 2, 'never' ],
     'comma-spacing': [ 2, { before: false, after: true } ],
     'comma-style': [ 2, 'last' ],
     'computed-property-spacing': [ 2, 'never' ],
     'consistent-this': 0,
     'eol-last': 2,
     'func-call-spacing': [ 2, 'never' ],
     'func-name-matching': 0,
     'func-names': 0,
     'func-style': [ 1, 'declaration' ],
     'id-blacklist': 0,
     'id-length': 0,
     'id-match': 0,
     indent:
      [ 2,
        'tab',
        { SwitchCase: 1,
          VariableDeclarator: 0,
          outerIIFEBody: 1,
          MemberExpression: 1,
          FunctionDeclaration: { body: 1, parameters: 0 },
          FunctionExpression: { body: 1, parameters: 0 } } ],
     'jsx-quotes': [ 2, 'prefer-double' ],
     'key-spacing': [ 2, { beforeColon: false, afterColon: true } ],
     'keyword-spacing': [ 2 ],
     'line-comment-position': 0,
     'linebreak-style': [ 2, 'unix' ],
     'lines-around-comment': [ 2, { beforeBlockComment: true, allowBlockStart: true } ],
     'lines-around-directive': [ 2, { before: 'never', after: 'always' } ],
     'max-depth': 0,
     'max-len': 0,
     'max-lines': 0,
     'max-nested-callbacks': 0,
     'max-params': [ 1, 4 ],
     'max-statements-per-line': [ 1, { max: 1 } ],
     'max-statements': 0,
     'multiline-ternary': 0,
     'new-cap': 0,
     'new-parens': 2,
     'newline-after-var': 0,
     'newline-per-chained-call': 0,
     'no-array-constructor': 2,
     'no-bitwise': 2,
     'no-continue': 0,
     'no-inline-comments': 0,
     'no-lonely-if': 2,
     'no-mixed-operators': 2,
     'no-mixed-spaces-and-tabs': 2,
     'no-multiple-empty-lines': 0,
     'no-negated-condition': 0,
     'no-nested-ternary': 0,
     'no-new-object': 2,
     'no-plusplus': 0,
     'no-restricted-syntax': 0,
     'no-tabs': 0,
     'no-ternary': 0,
     'no-trailing-spaces': 2,
     'no-underscore-dangle': 0,
     'no-unneeded-ternary': 2,
     'no-whitespace-before-property': 2,
     'object-curly-newline': [ 0, { multiline: true } ],
     'object-curly-spacing': 0,
     'one-var': 0,
     'one-var-declaration-per-line': 0,
     'operator-assignment': [ 2, 'always' ],
     'operator-linebreak': 0,
     'padded-blocks': 0,
     'quote-props': [ 2, 'consistent-as-needed' ],
     quotes: [ 2, 'single', 'avoid-escape' ],
     'require-jsdoc': 0,
     'semi-spacing': [ 2, { before: false, after: true } ],
     semi: [ 2, 'never' ],
     'sort-keys': 0,
     'sort-vars': 0,
     'space-before-blocks': [ 2, 'always' ],
     'space-before-function-paren': [ 2, 'always' ],
     'space-in-parens': 0,
     'space-infix-ops': 2,
     'space-unary-ops': 2,
     'spaced-comment': 2,
     'unicode-bom': [ 2, 'never' ],
     'wrap-regex': 2,
     'arrow-body-style': [ 2, 'as-needed' ],
     'arrow-parens': [ 2, 'always' ],
     'arrow-spacing': 2,
     'constructor-super': 2,
     'generator-star-spacing': [ 2, 'before' ],
     'no-class-assign': 2,
     'no-confusing-arrow': 2,
     'no-const-assign': 2,
     'no-dupe-class-members': 2,
     'no-duplicate-imports': 1,
     'no-new-symbol': 2,
     'no-restricted-imports': 0,
     'no-this-before-super': 2,
     'no-useless-computed-key': 2,
     'no-useless-constructor': 2,
     'no-useless-rename': 2,
     'no-var': 0,
     'object-shorthand': [ 2, 'never' ],
     'prefer-arrow-callback': 0,
     'prefer-const': 0,
     'prefer-numeric-literals': 2,
     'prefer-reflect': 0,
     'prefer-rest-params': 0,
     'prefer-spread': 0,
     'prefer-template': 0,
     'require-yield': 2,
     'rest-spread-spacing': [ 2, 'never' ],
     'sort-imports': 0,
     'symbol-description': 2,
     'template-curly-spacing': [ 2, 'never' ],
     'yield-star-spacing': [ 2, 'both' ],
     'babel/new-cap': 2,
     'babel/object-curly-spacing': 0 },
  parser: 'typescript-eslint-parser' }

The dev deps:

  "devDependencies": {
    "@babel/cli": "^7.1.5",
    "@babel/core": "^7.1.6",
    "@babel/plugin-proposal-class-properties": "^7.1.0",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/preset-env": "^7.1.6",
    "@babel/preset-typescript": "^7.1.0",
    "eslint": "^5.9.0",
    "eslint-plugin-babel": "^5.3.0",
    "eslint-plugin-typescript": "^0.13.0",
    "typescript": "^3.1.6",
    "typescript-eslint-parser": "^21.0.1"
  },

And the eslint run:

npx eslint --fix './source/**
@JamesHenry JamesHenry reopened this Jan 15, 2019
JamesHenry pushed a commit that referenced this issue Jan 17, 2019
## 2.2.0 (2018-08-25)

* ci: Added missing packages ([3938da6](unlight/eslint-plugin-tslint2@3938da6))
* ci(.travis.yml): Add greenkeeper-lockfile support (#7) ([706d9d6](unlight/eslint-plugin-tslint2@706d9d6)), closes [#7](https://github.com/unlight/eslint-plugin-tslint2/issues/7)
* Merge branch 'dev' ([db9bf0e](unlight/eslint-plugin-tslint2@db9bf0e))
* docs: Updated README ([b6947be](unlight/eslint-plugin-tslint2@b6947be))
* chore: Disabled package-lock ([07fa1d6](unlight/eslint-plugin-tslint2@07fa1d6))
* chore: Removed old infrastructure code ([43f5b4e](unlight/eslint-plugin-tslint2@43f5b4e))
* chore(package): Update @types/node to version 8.0.54 ([06c9397](unlight/eslint-plugin-tslint2@06c9397))
* chore(package): Update @types/node to version 8.0.57 (#18) ([719dc89](unlight/eslint-plugin-tslint2@719dc89)), closes [#18](https://github.com/unlight/eslint-plugin-tslint2/issues/18)
* chore(package): Update @types/node to version 8.0.58 (#20) ([a1ed18f](unlight/eslint-plugin-tslint2@a1ed18f)), closes [#20](https://github.com/unlight/eslint-plugin-tslint2/issues/20)
* chore(package): Update eslint to version 4.12.0 (#8) ([041551c](unlight/eslint-plugin-tslint2@041551c)), closes [#8](https://github.com/unlight/eslint-plugin-tslint2/issues/8)
* chore(package): Update eslint to version 4.12.1 (#11) ([5124913](unlight/eslint-plugin-tslint2@5124913)), closes [#11](https://github.com/unlight/eslint-plugin-tslint2/issues/11)
* chore(package): Update eslint to version 4.13.0 (#17) ([2695502](unlight/eslint-plugin-tslint2@2695502)), closes [#17](https://github.com/unlight/eslint-plugin-tslint2/issues/17)
* chore(package): update eslint to version 4.13.1 ([7f1b4fa](unlight/eslint-plugin-tslint2@7f1b4fa))
* chore(package): Update lint-staged to to version 6.0.0 (#12) ([040ec25](unlight/eslint-plugin-tslint2@040ec25)), closes [#12](https://github.com/unlight/eslint-plugin-tslint2/issues/12)
* chore(package): Update prettier-eslint-cli to version 4.4.2 ([2d024f3](unlight/eslint-plugin-tslint2@2d024f3)), closes [#13](https://github.com/unlight/eslint-plugin-tslint2/issues/13)
* chore(package): Update typescript to to version 2.6.2 (#9) ([25661af](unlight/eslint-plugin-tslint2@25661af)), closes [#9](https://github.com/unlight/eslint-plugin-tslint2/issues/9)
* chore(package): Update typescript-eslint-parser to version 10.0.0 (#19) ([4b9230b](unlight/eslint-plugin-tslint2@4b9230b)), closes [#19](https://github.com/unlight/eslint-plugin-tslint2/issues/19)
* chore(package): Update typescript-eslint-parser to version 9.0.1 (#10) ([a39256c](unlight/eslint-plugin-tslint2@a39256c)), closes [#10](https://github.com/unlight/eslint-plugin-tslint2/issues/10)
* chore(README): Banner URL ([d0ac4d2](unlight/eslint-plugin-tslint2@d0ac4d2))
* chore(travis): Whitelist greenkeeper branches (#6) ([4cc915b](unlight/eslint-plugin-tslint2@4cc915b)), closes [#6](https://github.com/unlight/eslint-plugin-tslint2/issues/6)
* refactor: Rewritten always-fail-rule in es2015 style ([651b629](unlight/eslint-plugin-tslint2@651b629))
* style: Changed indent to 4 spaces ([bfa7756](unlight/eslint-plugin-tslint2@bfa7756))
* feat(core): Added support rules requires type information ([6bc1deb](unlight/eslint-plugin-tslint2@6bc1deb)), closes [#32](https://github.com/unlight/eslint-plugin-tslint2/issues/32) [#34](https://github.com/unlight/eslint-plugin-tslint2/issues/34)
JamesHenry pushed a commit that referenced this issue Jan 17, 2019
## 2.2.0 (2018-08-25)

* ci: Added missing packages ([3938da6](unlight/eslint-plugin-tslint2@3938da6))
* ci(.travis.yml): Add greenkeeper-lockfile support (#7) ([706d9d6](unlight/eslint-plugin-tslint2@706d9d6)), closes [#7](https://github.com/unlight/eslint-plugin-tslint2/issues/7)
* Merge branch 'dev' ([db9bf0e](unlight/eslint-plugin-tslint2@db9bf0e))
* docs: Updated README ([b6947be](unlight/eslint-plugin-tslint2@b6947be))
* chore: Disabled package-lock ([07fa1d6](unlight/eslint-plugin-tslint2@07fa1d6))
* chore: Removed old infrastructure code ([43f5b4e](unlight/eslint-plugin-tslint2@43f5b4e))
* chore(package): Update @types/node to version 8.0.54 ([06c9397](unlight/eslint-plugin-tslint2@06c9397))
* chore(package): Update @types/node to version 8.0.57 (#18) ([719dc89](unlight/eslint-plugin-tslint2@719dc89)), closes [#18](https://github.com/unlight/eslint-plugin-tslint2/issues/18)
* chore(package): Update @types/node to version 8.0.58 (#20) ([a1ed18f](unlight/eslint-plugin-tslint2@a1ed18f)), closes [#20](https://github.com/unlight/eslint-plugin-tslint2/issues/20)
* chore(package): Update eslint to version 4.12.0 (#8) ([041551c](unlight/eslint-plugin-tslint2@041551c)), closes [#8](https://github.com/unlight/eslint-plugin-tslint2/issues/8)
* chore(package): Update eslint to version 4.12.1 (#11) ([5124913](unlight/eslint-plugin-tslint2@5124913)), closes [#11](https://github.com/unlight/eslint-plugin-tslint2/issues/11)
* chore(package): Update eslint to version 4.13.0 (#17) ([2695502](unlight/eslint-plugin-tslint2@2695502)), closes [#17](https://github.com/unlight/eslint-plugin-tslint2/issues/17)
* chore(package): update eslint to version 4.13.1 ([7f1b4fa](unlight/eslint-plugin-tslint2@7f1b4fa))
* chore(package): Update lint-staged to to version 6.0.0 (#12) ([040ec25](unlight/eslint-plugin-tslint2@040ec25)), closes [#12](https://github.com/unlight/eslint-plugin-tslint2/issues/12)
* chore(package): Update prettier-eslint-cli to version 4.4.2 ([2d024f3](unlight/eslint-plugin-tslint2@2d024f3)), closes [#13](https://github.com/unlight/eslint-plugin-tslint2/issues/13)
* chore(package): Update typescript to to version 2.6.2 (#9) ([25661af](unlight/eslint-plugin-tslint2@25661af)), closes [#9](https://github.com/unlight/eslint-plugin-tslint2/issues/9)
* chore(package): Update typescript-eslint-parser to version 10.0.0 (#19) ([4b9230b](unlight/eslint-plugin-tslint2@4b9230b)), closes [#19](https://github.com/unlight/eslint-plugin-tslint2/issues/19)
* chore(package): Update typescript-eslint-parser to version 9.0.1 (#10) ([a39256c](unlight/eslint-plugin-tslint2@a39256c)), closes [#10](https://github.com/unlight/eslint-plugin-tslint2/issues/10)
* chore(README): Banner URL ([d0ac4d2](unlight/eslint-plugin-tslint2@d0ac4d2))
* chore(travis): Whitelist greenkeeper branches (#6) ([4cc915b](unlight/eslint-plugin-tslint2@4cc915b)), closes [#6](https://github.com/unlight/eslint-plugin-tslint2/issues/6)
* refactor: Rewritten always-fail-rule in es2015 style ([651b629](unlight/eslint-plugin-tslint2@651b629))
* style: Changed indent to 4 spaces ([bfa7756](unlight/eslint-plugin-tslint2@bfa7756))
* feat(core): Added support rules requires type information ([6bc1deb](unlight/eslint-plugin-tslint2@6bc1deb)), closes [#32](https://github.com/unlight/eslint-plugin-tslint2/issues/32) [#34](https://github.com/unlight/eslint-plugin-tslint2/issues/34)
@JamesHenry JamesHenry added the package: parser Issues related to @typescript-eslint/parser label Jan 18, 2019
@bradzacher bradzacher added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin migration-test and removed package: parser Issues related to @typescript-eslint/parser labels Jan 18, 2019
@armano2
Copy link
Member

armano2 commented Feb 12, 2019

@balupton issue got fixed and should work in > 1.3.1-alpha10

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants