Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add undefined to return type of array-last #447

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sunnyzanchi
Copy link

It's possible for array-last to return undefined, so it should be included in the return type. If there's a more sophisticated typing that makes sense here i'm happy to change it

✔️ Updated tests and yarn test-types passes

It's possible for array-last to return `undefined`,
so it should be included in the return type
@angus-c
Copy link
Owner

angus-c commented Apr 30, 2022

Not a TS expert so I may be wrong, but I don't this change is necessary.
See https://tinyurl.com/2p9fjbct. (this is with StrictNullChecks on)

Also in index.tests.ts probably just needs
const test8: undefined = last([undefined]);

@sunnyzanchi
Copy link
Author

in this example, the definition of last errors with dynamic arrays — i think this is maybe from a newer version of TS, i don't remember this happening before. last2 doesn't let TS catch that d might be undefined. i think the type definition of last3 is the only one that covers all cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants