Skip to content

Fix bug: ClassDeclaration not guaranteed to be first declaration of a class#22983

Merged
3 commits merged into
masterfrom
codeFixAddMissingMember_classIsNotFirstDeclaration
Mar 29, 2018
Merged

Fix bug: ClassDeclaration not guaranteed to be first declaration of a class#22983
3 commits merged into
masterfrom
codeFixAddMissingMember_classIsNotFirstDeclaration

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Mar 29, 2018

Fixes #22479

////new C().x = 0;

verify.codeFix({
description: "Declare property 'foo'",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shouldnt this be "x" instead of "foo"

if (!(symbol && leftExpressionType.flags & TypeFlags.Object && symbol.flags & SymbolFlags.Class)) {
return undefined;
}
const classDeclaration = cast(first(symbol.declarations), isClassLike);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we check that we found a class?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think it should be guaranteed to exist if the symbol has SymbolFlags.Class.

@ghost
Copy link
Copy Markdown
Author

ghost commented Mar 29, 2018

Thanks to #22987 this is now just adding a test.

@ghost ghost merged commit 4309c0e into master Mar 29, 2018
@ghost ghost deleted the codeFixAddMissingMember_classIsNotFirstDeclaration branch March 29, 2018 21:55
@microsoft microsoft locked and limited conversation to collaborators Jul 26, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants