Skip to content

disallow acesssor generate in function like initializer - #24187

Merged
Mohamed Hegazy (mhegazy) merged 2 commits into
microsoft:masterfrom
Kingwl:disallow-in-function-like-initializer
May 18, 2018
Merged

Mohamed Hegazy (mhegazy) merged 2 commits into
microsoft:masterfrom
Kingwl:disallow-in-function-like-initializer

Conversation

@Kingwl

Copy link
Copy Markdown
Contributor

Fixes #24174

verify.refactorAvailable("Generate 'get' and 'set' accessors");

goTo.select("e", "f");
verify.not.refactorAvailable("Generate 'get' and 'set' accessors");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would prefer just verify.not.refactorAvailable();, otherwise this test will trivially pass if we ever change the description.

const node = getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false);
const declaration = findAncestor(node.parent, isAcceptedDeclaration);
const declaration = <AcceptedDeclaration>findAncestor(node.parent, n => {
if (isFunctionLikeDeclaration(n)) {

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.

it is still wired that i can select the value, and get the refactoring.. e.g.:

class C {
    prop = [  1, 2 , 3  ]; // select 2
}

I think the better approach here is to make sure whatever declaration we found, its name is part of the original span..

@mhegazy
Mohamed Hegazy (mhegazy) merged commit 8c2ed97 into microsoft:master May 18, 2018
@Kingwl
Wenlu Wang (Kingwl) deleted the disallow-in-function-like-initializer branch May 18, 2018 03:17
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jul 31, 2018
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