Looking at the source code for the tslint rule, I came across the following statement:
if (node.parent!.kind === ts.SyntaxKind.ObjectLiteralExpression) { return; }
Pay attention to the operator ! after node.parent . Interesting!
At first I tried to compile the file locally with my installed version of TS (1.5.3). The error received indicated the exact location of the explosion:
$ tsc --noImplicitAny memberAccessRule.ts noPublicModifierRule.ts(57,24): error TS1005: ')' expected.
Then I upgraded to the latest version of TS (2.1.6), which compiled it without any problems. So this seems to be a feature of TS 2.x. But the transpilation completely ignored the hit, resulting in the following JS:
if (node.parent.kind === ts.SyntaxKind.ObjectLiteralExpression) { return; }
My google fu still failed me.
What is the TS exclamation mark operator and how does it work?
typescript tslint
Mike Chamberlain Feb 16 '17 at 12:22 2017-02-16 12:22
source share