Skip to content

The new NonNullable type doesn't work the same when combined with index typesΒ #50462

Closed
@niieani

Description

@niieani

Bug Report

πŸ”Ž Search Terms

NonNullable index

πŸ•— Version & Regression Information

  • This changed between versions 3.7.4 and 3.8.1-rc

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type Edge<Typename extends string = string> = {
  readonly events: ReadonlyArray<{ readonly __typename: Typename } | null>;
};

export type InnerEventTypename<EdgeT extends Edge> = NonNullable<EdgeT['events'][number]>['__typename'];

πŸ™ Actual behavior

Error: Type '"__typename"' cannot be used to index type 'NonNullable<EdgeT["events"][number]>'.

πŸ™‚ Expected behavior

No error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions