Feature Request: add TypeChecker API to query if identifier is definitely assigned #20221
Labels
API
Relates to the public API for TypeScript
In Discussion
Not yet reached consensus
Suggestion
An idea for TypeScript
Currently it's not possible to query CFA. I need to find out if an identifier is definitely assigned. This logic is part of
checkIdentifier
and is not accessible outside of that function.My use case is the TSLint rule
no-unnecessary-type-assertion
where we need to identify false positives. The current implementation compares the type before and after the non-null-assertion. That doesn't work well for identifiers that are not definitely assigned, because the assertion suppresses TS2454 and can therefore not be removed.The text was updated successfully, but these errors were encountered: