Skip to content

Allow for optional index signatures (for the sake of exactOptionalPropertyTypes) #46969

Open
@OliverJAsh

Description

@OliverJAsh

Bug Report

🔎 Search Terms

exactOptionalPropertyTypes strictoptionalProperties Partial index signature dictionary record

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about exactOptionalPropertyTypes

⏯ Playground Link

Playground link with relevant code

💻 Code

type MyRecord = { x: string; z: string };

const r: Partial<MyRecord> = {
    x: "y",
    // Error as expected ✅
    z: undefined,
};

type MyDict = { [key: string]: string };

const d: Partial<MyDict> = {
    x: "y",
    // Expected error but got none ❌
    z: undefined,
};

🙁 Actual behavior

See code comments above.

🙂 Expected behavior

See code comments above.


This was briefly discussed in #44524 and #44421 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions