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

Fix class expression from being assignable if types don't match #40660

Merged
merged 3 commits into from
Oct 5, 2020

Conversation

tiagovtristao
Copy link
Contributor

@tiagovtristao tiagovtristao commented Sep 20, 2020

This PR aims to fix #39469

A simpler code version highlighting the problem is seen below:

interface A {
  prop: string;
}

const A: {new(): A} = class {}

The const A declaration should be invalid since the initializer doesn't have the prop property.

Currently, the initializer is having members of the A symbol merged into it, which is invalid in this scenario. This is however the behaviour that it is expected for const declarations where the initializer is function-like, as seen in #26368.

@ghost
Copy link

ghost commented Sep 20, 2020

CLA assistant check
All CLA requirements met.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved getDeclarationOfExpando to getSymbolOfExpando in checker.ts. You'll need to make this change there.

@karol-majewski
Copy link

Thank you @tiagovtristao!

@sandersn sandersn merged commit 1191e2e into microsoft:master Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Class expressions: illegal assignments are allowed
6 participants