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

Wrong no-use-before-declare error #2210

Closed
MikeVitik opened this issue Feb 16, 2017 · 2 comments · Fixed by #2235
Closed

Wrong no-use-before-declare error #2210

MikeVitik opened this issue Feb 16, 2017 · 2 comments · Fixed by #2235

Comments

@MikeVitik
Copy link

Bug Report

  • TSLint version: "~4.4.2"
  • TypeScript version: 2.1.5
  • Running TSLint via: Visual Studio Code

TypeScript code being linted

class Greeter {
    greet(options: { str: string }) {
        var {str} = options;
        return str;
    }
}

with tslint.json configuration:

{
  "rules": {
    "ban": [true,
        ["_", "extend"],
        ["_", "isNull"],
        ["_", "isDefined"]
    ],
    "class-name": true,
    "curly": true,
    "eofline": false,
    "forin": false,
    "indent": [true, 4],
    "interface-name": true,
    "jsdoc-format": true,
    "label-position": true,
    "max-line-length": [true, 250],
    "no-arg": true,
    "no-bitwise": true,
    "no-console": [true,
        "debug",
        "info",
        "time",
        "timeEnd",
        "trace"
    ],
    "no-construct": true,
    "no-debugger": true,
    "no-duplicate-variable": true,
    "no-empty": false,
    "no-eval": true,
    "no-string-literal": false,
    "trailing-comma": true,
    "no-trailing-whitespace": true,
    "no-unused-expression": true,
    "no-unused-variable": true,
    "no-use-before-declare": true,
    "one-line": [true,
        "check-open-brace",
        "check-catch",
        "check-whitespace"
    ],
    "quotemark": [true, "double"],
    "radix": true,
    "semicolon": true,
    "triple-equals": [true, "allow-null-check"],
    "typedef": [true,
        "indexSignature",
        "propertySignature"
    ],
    "typedef-whitespace": [true,
        ["callSignature", "noSpace"],
        ["catchClause", "noSpace"],
        ["indexSignature", "space"]
    ],
    "variable-name": false,
    "whitespace": [false,
        "check-branch",
        "check-decl",
        "check-operator",
        "check-separator",
        "check-type"
    ]
  }
}```

#### Actual behavior
message: 'variable 'str' used before declaration (no-use-before-declare)'at: '2,22'source: 'tslint'

#### Expected behavior

no error
@adidahiya
Copy link
Contributor

looks like a bug, but it's pretty low priority for us because no-use-before-declare is expensive (performance-wise) and not very useful in general. we don't enable it in tslint:recommended.

@rwngallego
Copy link

So should not we use no-use-before-declare?

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