Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed inconsistent abstract constructor assignability and instantiation checks #60000

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bgenia
Copy link

@bgenia bgenia commented Sep 18, 2024

Fixes #59890

I tried to make abstract/concrete constructor relation behave similarly to other subtyping relations:

  1. Abstract/concrete constructor assignability is now checked for each individual signature
  2. Abstract constructor instantiation is now checked after signature resolution only for the resolved signature

The second change makes it possible to instantiate concrete constructors with abstract overloads if concrete overload is resolved.

type MixedConstructor =
  & (new (kind: "concrete") => void)
  & (abstract new (kind: "abstract") => void)

declare const MixedConstructor: MixedConstructor

new MixedConstructor("concrete") // ok
new MixedConstructor("abstract") // error

This is done mainly to eliminate inconsistencies between type relations and instantiation checks (signatures not actually being abstract but being treated as such) and make this behavior more intuitive.

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Sep 18, 2024
@bgenia

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Not started
2 participants