Skip to content

Declaring index signature based on property type gives invalid error #30982

Description

TypeScript Version: latest, demonstrable on playground (links below)

Search Terms: index signature diagnostics property type

Code:

interface BaseNode {
  kind: string;
  [key: string]: string | TokenNode["data"];
}

interface TokenNode extends BaseNode {
  kind: 'token';
  data: TokenData;
}

interface TokenData {
  offset: number;
  width: number;
  leading_width: number;
  trailing_width: number;
}

Expected behavior:

No errors, as the code is correct.

Actual behavior:

An error on interface TokenNode:

Interface 'TokenNode' incorrectly extends interface 'BaseNode'.
  Index signature is missing in type 'TokenNode'.

HOWEVER if I change TokenNode["data"] to its value TokenData, the error goes away.

Playground Link:

Code above displaying the error
Code above with the fix, no errors

Activity

  1. added
    Experience Enhancement
    Suggestion
    on Apr 17, 2019
  2. added
    Bug
    and removed
    Experience Enhancement
    Suggestion
    on Apr 17, 2019
  3. RyanCavanaugh commented on Apr 17, 2019

    @RyanCavanaugh
    Member

    Current behavior dates back to 2.1

  4. added
    Domain: Indexed Access Types
    on Oct 16, 2025
  5. added
    Domain: check: Order Dependence
    on Nov 18, 2026
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

    BugDomain: Indexed Access TypesDomain: check: Order Dependence

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions