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

False positive for no-shadowed-variable with multiple index definitions #1258

Closed
JoshuaKGoldberg opened this issue May 18, 2016 · 2 comments · Fixed by #1482
Closed

False positive for no-shadowed-variable with multiple index definitions #1258

JoshuaKGoldberg opened this issue May 18, 2016 · 2 comments · Fixed by #1482

Comments

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented May 18, 2016

Bug Report

  • TSLint version: 3.8.1
  • TypeScript version: 1.8.10
  • Running TSLint via: gulp-tslint

TypeScript code being linted

interface IFoo {
    [i: string]: any;
    [i: number]: any;
}

with tslint.json:

{
    "rules": {
        "no-shadowed-variable": true
    }
}

Actual behavior

(no-shadowed-variable) file.ts[6, 6]: shadowed variable: 'i'

Expected behavior

This should be fine, yes?

@ChrisMBarr
Copy link
Contributor

why not just write it like this?

interface IFoo {
    [i: string|number]: any;
}

@JoshuaKGoldberg
Copy link
Contributor Author

JoshuaKGoldberg commented Jun 16, 2016

@ChrisMBarr Not allowed before TS 1.5: microsoft/TypeScript#1715

Otherwise the bug still holds for the following:

interface IFoo {
    [i: string]: boolean;
    [i: number]: string | any;
}

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

Successfully merging a pull request may close this issue.

3 participants