Hi,
I have set
"typedef-whitespace": [
true,
{
"parameter": "space"
}
]
to enforce a space in front of the colon in method signatures. Unfortunately, what it seems to do is to force me to add a space after the parameter name, which only allows the following syntax for optional parameters:
public myMethod(name ?:string):void { /* Looks like an optional type */ }
public myAlternateMethod(name ? :string):void { /* Looks like a ternary operator */ }
which is not quite, what I want to have.
For me, it would be very nice, if I could define this syntax:
public myMethod(name? :string):void { /* empty*/ }
Am I overseeing a whitespace-rule for the optional flag?
This seems like a bug to me. I can't imagine anyone actually wants a space between the name and the ? of parameters (or fields or anything similar). Unfortunately there isn't any workaround that I know of.
Shouldn't this be fixed with #958? Before the PR, the rule would take the end of the parameter name, advance one character and check that one for being a space (which is obviously wrong for the optional flag). The PR fixed this by explicitly searching for the colon and checking the character in front of it.
@b0r3as Good call, I think you're right. We should add some regression tests to verify the fix.
Another lint error that I faced after updating tslint from 5.8.0 to 5.9.1:

I use ? to specify optional class property (and seems like it's a valid Typescript).
Config for whitelist rule:
"whitespace": [true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-rest-spread",
"check-type",
"check-typecast",
"check-type-operator",
"check-preblock"
]
Same issue using tslint 5.11.0
Per #4534, this is an old issue with a formatting concern that has aged away.
Why is this issue closed without being resolved?
Hi @ataravati! See #4534 (as linked in the comment just above yours). TSLint is deprecated and we're no longer accepting PRs for non-critical bugs such as this one.
Thank you, @JoshuaKGoldberg!
馃 Beep boop! 馃憠 TSLint is deprecated 馃憟 and you should switch to typescript-eslint! 馃
馃敀 This issue is being locked to prevent further unnecessary discussions. Thank you! 馃憢
Most helpful comment
Another lint error that I faced after updating tslint from
5.8.0to5.9.1:I use
?to specify optional class property (and seems like it's a valid Typescript).Config for
whitelistrule: