-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Given Array<T>
const index which not overflow, should indicate element type T
instead of T|undefined
#52842
Comments
Given the example I really don't see any purpose in this. It's easier and cleaner to just access the element and check for |
BackgroundThe purpose is parsing column base text into interface. The column base text definition is in linux kernel. The column is generated from Some columns are required, some columns are optional, based on columns length. Given
Actual
Expected
Workaround
// prettier-ignore
type LengthCaseArray<T> =
|[] & {length:0}
|[T] & {length:1}
|[T,T] & {length:2}
|[T,T,T] & {length:3}
|[T,T,T,T] & {length:4}
|[T,T,T,T,T] & {length:5}
|[T,T,T,T,T,T] & {length:6}
|[T,T,T,T,T,T,T] & {length:7}
|[T,T,T,T,T,T,T,T] & {length:8}
|[T,T,T,T,T,T,T,T,T] & {length:9}
|[T,T,T,T,T,T,T,T,T,T] & {length:10}
|[T,T,T,T,T,T,T,T,T,T,T] & {length:11}
|[T,T,T,T,T,T,T,T,T,T,T,T] & {length:12}
|[T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:13}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:14}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:15}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:16}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:17}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:18}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:19}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:20}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:21}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:22}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:23}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:24}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:25}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:26}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:27}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:28}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:29}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:30}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T] & {length:31}
|[T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,...T[]] & {length:number} |
This was a well-defined limitation in #39560. We're offering two options here:
Given that we can't fully track all possible array mutations, we don't intend to add a third in-between option, nor unsound behavior in the latter option. |
This issue has been marked as "Declined" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
🔎 Search Terms
Array<T>
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
🙂 Expected behavior
Additional
I guess there is already an issue.
But seems not easy to find which to track on from tons of issues.
The text was updated successfully, but these errors were encountered: