Skip to content

Should/could typeguarding work on arrays/length #10272

@normalser

Description

@normalser

TypeScript Version: @next

Code

//  --strictNullChecks
let args = process.argv.slice(2) // type: string[]
let test1 = args[Number.MAX_VALUE] // type: 'string' but should it be 'string | undefined' ?
if (args.length > 0) {
  let test2 = args.shift() // Type: 'string | undefined' - but should it be 'string' ?
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions