Closed
Description
Note: this issue was originally filed here eslint/typescript-eslint-parser#588.
The original issue (now archived) was marked as closed, and suggested as being fixed by eslint/typescript-eslint-parser#596, however it does still appear to be an issue when using the latest 1.0.0
versions of the parser & plugin from the @typescirpt-eslint
monorepo (unless I'm holding it wrong).
What code were you trying to parse?
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"rules": {
"no-magic-numbers": "error"
}
}
type Amount = 10 | -10;
const movement: Amount = 10
What did you expect to happen?
No errors
What actually happened?
1:15 error No magic number: 10 no-magic-numbers
1:20 error No magic number: -10 no-magic-numbers
The magic numbers that the rule is complaining about are the allowed values of the Typescript numeric literal type type Amount = 10 | -10.
I'm not aware of any way to define a numeric literal type that doesn't violate the magic numbers rule?
Versions
package | version |
---|---|
@typescript-eslint/parser |
1.0.0 |
TypeScript |
3.2.1 |
ESLint |
5.11.1 |
node |
11.5.0 |
npm |
6.5.0 |