class Foo {
bar() {
const params = {
{}
};
if (true === true) {
}
}
}
with tslint.json configuration:
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
]
}
tslint -c tslint.json kk.ts
The 'trailing-comma' rule threw an error in 'kk.ts':
TypeError: Cannot read property 'end' of undefined
at cb (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/tslint/5.11.0/node_modules/tslint/lib/rules/trailingCommaRule.js:163:133)
at visitNodes (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/typescript/3.0.3/node_modules/typescript/lib/typescript.js:15129:30)
at Object.forEachChild (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/typescript/3.0.3/node_modules/typescript/lib/typescript.js:15428:21)
at cb (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/tslint/5.11.0/node_modules/tslint/lib/rules/trailingCommaRule.js:170:23)
at visitNodes (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/typescript/3.0.3/node_modules/typescript/lib/typescript.js:15129:30)
at Object.forEachChild (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/typescript/3.0.3/node_modules/typescript/lib/typescript.js:15355:24)
at TrailingCommaWalker.walk (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/tslint/5.11.0/node_modules/tslint/lib/rules/trailingCommaRule.js:172:19)
at Rule.AbstractRule.applyWithWalker (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/tslint/5.11.0/node_modules/tslint/lib/language/rule/abstractRule.js:31:16)
at Rule.apply (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/tslint/5.11.0/node_modules/tslint/lib/rules/trailingCommaRule.js:64:21)
at Linter.applyRule (/private/tmp/tp-20180904190451/node_modules/.registry.npmjs.org/tslint/5.11.0/node_modules/tslint/lib/linter.js:197:29)
<snip>
It should not crash.
@jiripospisil to be fair, this is not valid javascript:
const params = {
{}
};

@jiripospisil to be fair, this is not valid javascript:
@giladgray I'm aware but it's easy to get into a state which is not valid TS/JS while in the middle of changing code.
To be clear, I'm not running TSLint manually, I'm using VSCode and it runs it automatically via vscode-tslint.

I'm fairly certain there are other ways to trigger this because I've encountered it multiple times but the provided snippet seems pretty reliable and should be enough to add some sort of a fail-safe.
Same issue, any updates on this one?

TypeError: Cannot read property 'end' of undefined
at cb (/Users/thomas.pink/Development/angular-components/node_modules/tslint/lib/rules/trailingCommaRule.js:163:133)
at visitNodes (/Users/thomas.pink/Development/angular-components/node_modules/typescript/lib/typescript.js:13272:30)
at Object.forEachChild (/Users/thomas.pink/Development/angular-components/node_modules/typescript/lib/typescript.js:13421:24)
at cb (/Users/thomas.pink/Development/angular-components/node_modules/tslint/lib/rules/trailingCommaRule.js:170:23)
at visitNode (/Users/thomas.pink/Development/angular-components/node_modules/typescript/lib/typescript.js:13263:24)
at Object.forEachChild (/Users/thomas.pink/Development/angular-components/node_modules/typescript/lib/typescript.js:13446:24)
at cb (/Users/thomas.pink/Development/angular-components/node_modules/tslint/lib/rules/trailingCommaRule.js:170:23)
at visitNode (/Users/thomas.pink/Development/angular-components/node_modules/typescript/lib/typescript.js:13263:24)
at Object.forEachChild (/Users/thomas.pink/Development/angular-components/node_modules/typescript/lib/typescript.js:13457:24)
at cb (/Users/thomas.pink/Development/angular-components/node_modules/tslint/lib/rules/trailingCommaRule.js:170:23)
Duplicate of #3808
Most helpful comment
@giladgray I'm aware but it's easy to get into a state which is not valid TS/JS while in the middle of changing code.
To be clear, I'm not running TSLint manually, I'm using VSCode and it runs it automatically via vscode-tslint.
I'm fairly certain there are other ways to trigger this because I've encountered it multiple times but the provided snippet seems pretty reliable and should be enough to add some sort of a fail-safe.