Repository navigation
Emit issue with member access dot operator and parentheses usually in conjunction with type assertion #15444
Description
Activity
Unfortunately these are the JavaScript Automatic SemiColon Insertion rules.
TypeScript is a super-set of JavaScript, and the samples above are valid JS code samples, and they have valid semantics. the emitted code has to match these semantics.
- addedWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
on Apr 28, 2017 thanks for your reply Mohamed Hegazy (@mhegazy). i thought that it is a tricky case, as sometimes a multiline expression might be intended.
i might create a tslint warning to detect it in conjunction with assertions. or might this be a case where
tsccan warn itself?RyanCavanaugh commented
on Apr 28, 2017 MemberMore actionsI believe there's already a TSLint rule for missing semicolons
do you mean this
tslintcore rule:"semicolon": [true, "never"]"never" disallows semicolons at the end of every statement except for when they are necessary.
the rule does not warn if a semicolon in conjunction with a type assertion might be required. it also fails in some other cases, and warns. for example:
super(); <-- rule thinks this is unnecessary (a as Bar).foo()RyanCavanaugh commented
on Apr 28, 2017 MemberMore actionsSorry, I totally misread that. Disregard.
Mohamed Hegazy (@mhegazy) perhaps we should disallow
booleanas an operand to>/<, even if the other operand isany?Reacted by Gerard DelmàsGerard Delmàs (@gdelmas) you can use the
no-unexpected-multilineprovided bytslint-eslint-rulesReacted by Gerard DelmàsMohamed Hegazy (@mhegazy) perhaps we should disallow boolean as an operand to > / <, even if the other operand is any
👍
Filed #15506 to track it.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
- added a commit that references this issue
on May 24, 2017 - locked and limited conversation to collaborators
on Jun 14, 2018
Code
Expected emit:
Actual emit:
This becomes an issue when using type assertions inline:
Code
Expected emit:
Actual emit:
Angle brackets type assertion have a similar issue:
Code
Actual emit: