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

no-unsafe-any when using typed moment library #3988

Closed
DylanRJohnston opened this issue Jun 22, 2018 · 2 comments
Closed

no-unsafe-any when using typed moment library #3988

DylanRJohnston opened this issue Jun 22, 2018 · 2 comments

Comments

@DylanRJohnston
Copy link

DylanRJohnston commented Jun 22, 2018

Bug Report

  • TSLint version: 5.10.0
  • TypeScript version: 2.9.2
  • Running TSLint via: (pick one) CLI

TypeScript code being linted

import moment from 'moment'

const foo = moment()

with tslint.json configuration:

{
  "extends": ["tslint:all", "tslint-config-prettier"],
  "rules": {
    "ban-comma-operator": false,
    "ban-types": {
      "options": [
        ["Object", "Avoid using the `Object` type. Did you mean `object`?"],
        ["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
        ["Number", "Avoid using the `Number` type. Did you mean `number`?"],
        ["String", "Avoid using the `String` type. Did you mean `string`?"],
        ["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"]
      ]
    },
    "completed-docs": false,
    "interface-name": [true, "never-prefix"],
    "no-default-export": false,
    "no-empty-interface": false,
    "no-implicit-dependencies": [true, "dev"],
    "no-magic-numbers": [true, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
    "no-unbound-method": false,
    "no-void-expression": [true, "ignore-arrow-function-shorthand"],
    "strict-boolean-expressions": false,
    "type-literal-delimiter": false,
    "typedef": false
  }
}

Actual behavior

ERROR: 3:13 no-unsafe-any Unsafe use of expression of type 'any'.

Expected behavior

No error

The moment library is well typed, typescript doesn't complain at all during compilation, hovering over the variable in vscode shows that type is moment.Moment but tslint doesn't seem convinced.

@DylanRJohnston
Copy link
Author

Turning off no-unused-variable in tslint removes this issue, this is fine because the Typescript compiler already catches this problem.

@DylanRJohnston
Copy link
Author

Seems related to #2649

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

No branches or pull requests

1 participant