Skip to content

behavior of noUncheckedIndexedAccess is inconsistent.Β #57794

Description

πŸ”Ž 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

typeArr=string[]typeT1=Arr[0]// ^? type T1 = stringdeclareconstarr: Arrconstt1=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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions