Skip to content

Variance annotations are not allowed in type aliases for interfacesΒ #56390

Closed
@bgenia

Description

@bgenia

πŸ”Ž Search Terms

variance annotations

πŸ•— Version & Regression Information

  • This seems to be a bug
  • This is the behavior in every version I tried since variance annotations came out

⏯ Playground Link

https://www.typescriptlang.org/play?#code/C4TwDgpgBAKgYgewQHgGoEMA2BXCA+KAXigG8oA3LXALigx2gF8AoUSWAIXQCdkBLAHZQE2YHSr4isRCnq4CAegVQA8gGlmzQcAjcAZugDG0AJIy0EgmUoNacploE79R0116Dho8QwIQAHjoCACYAzlBmSBa+pIxQSqoarODQ7vxCImL2BMQmadnxygCi3NwI3MxAA

πŸ’» Code

type TFoo<Value> = { value: Value }
type TBar<in out Value> = TFoo<Value> // OK

interface IFoo<Value> { value: Value }
interface IBar<in out Value> extends IFoo<Value> {} // OK

type Bar<in out Value> = IBar<Value> // Error

πŸ™ Actual behavior

The error says that variance annotations are only allowed for object types, but IBar is an object type.

πŸ™‚ Expected behavior

There should be no errors

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions