millsp / ts-toolbelt

👷 TypeScript's largest type utility library

Home Page:https://millsp.github.io/ts-toolbelt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

:lady_beetle: `List.Pop<L>` not working with single entry arrays

rubenaeg opened this issue · comments

commented

🐞 Bug Report

Describe the bug

When using List.Pop<L> with only one entry in the list, the resulting type is an empty list instead of the single element.

Reproduce the bug

// This throws a compiler error
const invalid: List.Pop<['key']> = ['key'];

// This works
const valid: List.Pop<['key']> = [];

Expected behavior

I would expect the type to behave similar to Array.pop(), and it's description lets one assume that it does, but the above example showcases that this is not the case.

Possible Solution

I'm currently testing out a solution for this, as soon as I have more insight I will update the issue.

Screenshots

Additional context