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

behavior of noUncheckedIndexedAccess is inconsistent. #57794

Closed
13OnTheCode opened this issue Mar 15, 2024 · 2 comments
Closed

behavior of noUncheckedIndexedAccess is inconsistent. #57794

13OnTheCode opened this issue Mar 15, 2024 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@13OnTheCode
Copy link

πŸ”Ž Search Terms

"noUncheckedIndexedAccess" "undefined"

πŸ•— Version & Regression Information

5.4.2

⏯ Playground Link

https://www.typescriptlang.org/play?noUncheckedIndexedAccess=true&exactOptionalPropertyTypes=false&noPropertyAccessFromIndexSignature=false#code/C4TwDgpgBAggTnKBeKBnYcCWA7A5gbQF0AoY0SKAFQEZlYF8AGEgehag4D0B+UgEwgBjADYBDONEEB7bOiji4ALnpxS02cCjBaKBU1bsOUHsSA

πŸ’» Code

type Arr = string[]

type T1 = Arr[0]
//     ^?  type T1 = string

declare const arr: Arr

const t1 = arr[0]
//      ^?  const t1: string | undefined

πŸ™ Actual behavior

behavior of noUncheckedIndexedAccess is inconsistent.

πŸ™‚ Expected behavior

The type obtained from type T1 = Arr[0] should be string | undefined.

Additional information about the issue

No response

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Mar 15, 2024
@RyanCavanaugh
Copy link
Member

Intentional; see discussion on this at #39560

@MartinJohns
Copy link
Contributor

MartinJohns commented Mar 15, 2024

Duplicate of #42471.

edit: awww, too slow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants