Tslint: block is empty should allow for field declarations in constructor parameters

Created on 22 Jan 2014  路  2Comments  路  Source: palantir/tslint

The following code currently reports as "block is empty", but because it's a constructor with parameters that define fields, the empty block is needed and shouldn't be considered an error.

class Compile implements ng.IDirective {
    constructor(private $compile: ng.ICompileService) {
    }
}

Most helpful comment

Cool, that works well as a workaround.

If it's going to be too hard to implement it might be worth documenting this somewhere as a known issue, in case someone else runs into the same problem in the future.

All 2 comments

I think that's too much logic to check for from the linter. Would it be okay on your end to just add an empty comment in the constructor block like so:

constructor(private $compile: ng.ICompileService) {
    //
}

Cool, that works well as a workaround.

If it's going to be too hard to implement it might be worth documenting this somewhere as a known issue, in case someone else runs into the same problem in the future.

Was this page helpful?
0 / 5 - 0 ratings