Skip to content

Conditional type doesn't work inside tuple #40067

Description

TypeScript Version: 4.1.0-dev.20200807

Search Terms: conditional type tuple

Code

type Tuple<T> = [T extends null ? T? : T];

Expected behavior:
Expected the definition to work as expected.

Actual behavior:
Got the following error:

JSDoc types can only be used inside documentation comments.

Playground Link: Playground Link

Related Issues: Did not find anything close.

Activity

  1. jack-williams commented on Aug 15, 2020

    @jack-williams
    Collaborator

    As per #24897, outside of JSDoc the ? modifier is only valid for tuple elements, not arbitrary types. It does not make sense to say that a type can be omitted, only that an element can be omitted.

  2. ienzam commented on Aug 18, 2020

    @ienzam
    Author

    The above definition is inside a tuple, and one way to look at that is the element can be omitted or not.
    But I guess that messes up in other ways like making sure all the other elements are optional too.

  3. typescript-bot commented on Sep 5, 2020

    @typescript-bot
    Contributor

    This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
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