Interfaces can be written with semicolon delimiters, comma delimiters, or no delimiter at all.
Currently, TSLint will require the following trailing comma if you don't use any delimiter, and this is awkward:
interface Post {
title: string
age: number,
}
__Proposal__: enhance the rule logic to only require the trailing comma if the other fields have trailing commas.
reported by @schickling and @Zjaaspoer in #960
@adidahiya I'm trying to聽get failing tests to reproduce this issue, but still no errors on master branch
I'm altering files in test/rules/trailing-comma/multiline-always
tslint.json
{
"rules": {
"trailing-comma": [true, {"multiline": "always"}]
}
}
test.ts.lint
interface Post {
title: string
age: number
}
interface Post2 {
title: string,
age: number
}
Am I missing something?
Also, please consider cases such as:
type EventEmitterMap = {
[K in keyof DocumentEventMap]: EventEmitter<K>
} & {
onfoo: EventEmitter<{foo: Foo}>
onbar: EventEmitter<{bar: Bar}>
}
It would be nice to require trailing commas for array literals, object literals, function declarations and function calls, and type literals, but _also_ require that no commas are ever used at the end of lines for interface, where the commas are redundant.
What is the status here?
This should have been fixed by #2236. 馃帀
Closing for housekeeping purposes, but please do file a new issue or comment here if that's not the case!
Most helpful comment
What is the status here?