<number><any>value
with tslint.json configuration:
{
"rules": {
"no-angle-bracket-type-assertion": true
}
}
value as number as any
value as any as number
Some random thoughts:
The AST is a bit weird when dealing with type assertions. That may be the problem.
Or it's related to the sorting of the fixes, because both start at the same position and tslint usually sorts them by end position in descending order. Which will result in unexpected results when the length of the replacements differs.
Ehh, this particular sample is part of the test cases and I can't reproduce it. I'll close as related to #2955.
Got it. It is in fact sorting of the fixes.
It's failing locally when I change the rule's test.ts.lint file to:
var a = <any>5;
~~~~~~ [Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.]
var b = <number><any>5;
~~~~~~~~~~~~~~ [Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.]
~~~~~~ [Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.]
var c = <number>(5 as any);
~~~~~~~~~~~~~~~~~~ [Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.]
var d = <any> 5 as number;
~~~~~~~ [Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.]
var e = 5 as any as number;
var f = <number><any>d & e;
~~~~~~~~~~~~~~ [Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.]
~~~~~~ [Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.]
var f = <number><any>d & e;
~~~~~~~~~~~~~~ [Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.]
~~~~~~ [Type assertion using the '<>' syntax is forbidden. Use the 'as' syntax instead.]
```
Expected (from .fix file):
var b = 5 as number as any;
Actual (from TSLint):
var b = 5 as any as number;
Possibly related, --fix sometimes (in more complex code) "corrects" generic parameters: Foo<Bar> => Foo as Bar. It doesn't do this all the time though, and haven't figured out a good (simple) test file for a bug report yet....
Most helpful comment
Got it. It is in fact sorting of the fixes.
It's failing locally when I change the rule's
test.ts.lintfile to:```
Expected (from .fix file):
Actual (from TSLint):