Skip to content

Defining a type predicate breaks inheritance for methods with mapped types #56133

Description

🔎 Search Terms

type predicate mapped

🕗 Version & Regression Information

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

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.2.2#code/IYIwzgLgTsDGEAJYBthjAgglEBLawUAngDwAqAfAgN4BQCCokM8SwAdgMoAWUu7AawDq+bgHsArhADCY9hACmADwgAKAG7BkEhQC4EEwezEB3dgEp9m7QoS4MZANy16jcAVZKiAL2+kAqhjKiuwAJhiGAsZmANoAuhSqrgxK+tQIMQDSduwIAgpEYgBmCIFx+oFZcQgAvgA0rpZYOPgwxCSBFM41LkweiChoGACyRNh4BO2UCMEKYRjjrYSk03QMfSyIXr4BQSpz4QZGpuzxickIqTQZ2fx5BcWlYOVPVbUNDE2Lk7tdtD1AA

💻 Code

abstractclassArbitrary<T>{abstractcanShrinkWithoutContext(value: unknown): value is T;abstractxyzzy<Usextendsunknown[]>(x: {[KinkeyofUs]: Us[K]},): Arbitrary<Us>;}abstractclassMyArbitrary<T>extendsArbitrary<T>{abstractxyzzy<Usextendsunknown[]>(x: {[KinkeyofUs]: Us[K]},): Arbitrary<Us>;}

🙁 Actual behavior

The compiler reports an error in MyArbitrary unless canShrinkWithoutContext is removed or its return type is changed.

🙂 Expected behavior

The xyzzy method should be overridden in the derived class.

Additional information about the issue

No response

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions