-
Notifications
You must be signed in to change notification settings - Fork 13.4k
allow narrowing from any #9999
Copy link
Copy link
Closed
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
Milestone
Metadata
Metadata
Assignees
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
There are numerous questions as to why
anycannot 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
anyis not what you think it is (poor naming at play)type unknown = {} | undefined | null | voidinstead*.d.tsby handsUPDATE
@yortus made a branch per #9999 (comment) where narrowing from
anyworks!try it:
npm install typescript-narrowany