-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
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 code
document.querySelector('_')?.textContent!.split('') ?? 0 // string[]
document.querySelector('_')?.textContent?.split('') ?? 0 // string[] | 0
Expected behavior:
document.querySelector('_')!.textContent!.split('') // old code
document.querySelector('_')?.textContent!.split('') ?? 0 // unsafe, warning
document.querySelector('_')?.textContent?.split('') ?? 0 // safe
Actual behavior:
document.querySelector('_')!.textContent!.split('') // old code
document.querySelector('_')?.textContent!.split('') ?? 0 // unsafe, no warning
document.querySelector('_')?.textContent?.split('') ?? 0 // safe
Playground Link:
Related Issues:
Raiondesu
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript