sindresorhus / ts-extras

Essential utilities for TypeScript projects
MIT License
587 stars 15 forks source link

`setHas` and `arrayIncludes` are unsafe #59

Open russelldavis opened 8 months ago

russelldavis commented 8 months ago

Because type predicates also narrow in the false case, when setHas or arrayIncludes return false, you can end up with incorrect types. More details and examples at https://github.com/total-typescript/ts-reset/pull/125#issuecomment-1926133512

cc @tychenjiajun @younho9

russelldavis commented 7 months ago

Edited to add that arrayIncludes is unsafe for the same reason.