This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 885
Multiline trailing comma rule flags type parameters #1769
Labels
Comments
Perhaps more options need to be available, see eslint comma-dangle. With TSLint we need an option for generics. |
yeah, makes sense, if it is not valid TypeScript then TSLint should not flag it as a violation. accepting PRs to fix this in the default rule behavior |
wmrowan
added a commit
to plaid/tslint
that referenced
this issue
Nov 22, 2016
Typescript disallows trailing commas in type parameter lists, both on declaration and invocation. Linting should not flag this case as fixing the lint error would introduce a compiler error. See palantir#1769
Missing such case: var foo = <
A,
B
~ [Missing trailing comma] // expecting no warnings
>(a: A, b: B) => 42; This issue should be reopened. |
I found another case: function foo(a: [
number,
string
~ [Missing trailing comma] // expecting no warnings
]): void {
return 42;
} |
Is there any workaround to get this fixed or we just need to sicked with |
this was fixed by a277873, available in v4.1+ |
I tested @mizunashi-mana's 2 test cases above and they're not fixed in 4.3.1 |
actually, #1905 was opened to cover those issues |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug Report
4.0.1
2.1.1
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
TSLint flags line 3 in the sample code as a lint error. TSLint says that this line should have a trailing comma.
Expected behavior
TSLint should not flag this as a lint failure as a trailing comma is not allowed here by Typescript. Adding a comma to satisfy the linter will result in a Typescript compile error. While I think I personally agree with TSLint that a comma should be allowed here to be consistent with non-type function arguments, Typescript nevertheless disallows this syntax. While I think it would be reasonable to ask Typescript to fix this inconsistency, TSLint should probably be consistent with Typescript in the meantime.
The text was updated successfully, but these errors were encountered: