Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

allow narrowing from any #9999

Copy link
Copy link
@zpdDG4gta8XKpMCd

Description

@zpdDG4gta8XKpMCd
Issue body actions

There are numerous questions as to why any cannot be narrowed from. Despite being natural and intuitive this feature was rejected due to being a serious breaking change to poorly written yet massive code bases.

Please consider putting it behind a flag provided the evident need for it.

TLDR

  • any is not what you think it is (poor naming at play)
  • for narrowing use type unknown = {} | undefined | null | void instead
  • yes, it's a hot unfortunate mess
  • no, there is no painless way to fix it
  • yes, you gonna need to fix your *.d.ts by hands
  • why? to make average JS developers happy with their less than perfect code
  • welcome to the club! get your badge at the reception

UPDATE
@yortus made a branch per #9999 (comment) where narrowing from any works!

try it: npm install typescript-narrowany

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeCommittedThe team has roadmapped this issueThe team has roadmapped this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.