Encountered an issue with the no-let
rule in my tslint
configuration. It is flagging the handler
variable as requiring a const
declaration, despite the fact that it is assigned within a switch
case statement. This seems like a potential bug to me.
static def(name: string) {
// [tslint]Unexpected let, use const instead (no-let)
let handler: Function;
switch (name) {
case 'test':
handler = console.error;
break;
default:
handler = console.warn;
}
handler(name);
}
Attempting to change it to const handler: Function
results in an error being thrown by tsserver
.
const handler: Function;
switch (name) {
case 'test':
// [tsserver] Cannot assign to 'handler' because it's a constant
handler = console.error;
break;