You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an anti-pattern on the current type system. And the compiler must not do quick fix so. !. after ?. is simply replaceable with ?. and should do so.
TypeScript Version: 3.7.x-dev.20191105
Search Terms:
Code
document.querySelector('_')!.textContent!.split('')// old codedocument.querySelector('_')?.textContent!.split('')??0// string[]document.querySelector('_')?.textContent?.split('')??0// string[] | 0
Expected behavior:
document.querySelector('_')!.textContent!.split('')// old codedocument.querySelector('_')?.textContent!.split('')??0// unsafe, warningdocument.querySelector('_')?.textContent?.split('')??0// safe
Actual behavior:
document.querySelector('_')!.textContent!.split('')// old codedocument.querySelector('_')?.textContent!.split('')??0// unsafe, no warningdocument.querySelector('_')?.textContent?.split('')??0// safe
This issue has meaning without adopting #35025 and meaningless if #35025 is adopted. So this issue and #35025 are in opposition. This is the definitive difference.
Activity
kitsonk commentedon Nov 13, 2019
Isn't this a just linting rule? Whenever you use
!it is potentially unsafe. The compiler never warns, an error is an error.falsandtru commentedon Nov 13, 2019
When quick fix observes this rule, it is wasteful splitting.
RyanCavanaugh commentedon Nov 13, 2019
falsandtru (@falsandtru) some discussion about what exactly is different between this and #35025 would be nice
falsandtru commentedon Nov 13, 2019
This issue has meaning without adopting #35025 and meaningless if #35025 is adopted. So this issue and #35025 are in opposition. This is the definitive difference.