Skip to content

Feature Request: add TypeChecker API to query if identifier is definitely assigned #20221

@ajafff

Description

@ajafff

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: APIRelates to the public API for TypeScriptIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions