Making Sense of 'No Shadowed Variable' tslint Warning

another way to say makes more sense
make sense example sentence
define make sense of synonym
make the most sense
acronym for make sense
formal way of saying makes sense
understand synonym
another way to say doesn't make sense

I have a function that checks for the current stage in a sequential stream, based on a particular discipline that is passed in, and, according to that value, assigns the next value in my Angular 2 app. It looks something like this:

private getNextStageStep(currentDisciplineSelected) {
    const nextStageStep = '';
        if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 1') {
            const nextStageStep = 'step 2';
        } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 2') {
            const nextStageStep = 'step 3';
        } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 3') {
            const nextStageStep = 'step 4';
        } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 4') {
            const nextStageStep = 'step 5';
        } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 5') {
            const nextStageStep = 'step 6';
    }
    return nextStageStep;
}

What I'm doing here is returning the value of "nextStageStep", because that's what I'll be then passing in order for the correct stage step to happen.

Right now, my tslint is underlining each of the "nextStageStep" variable occurrences with the warning "no shadowed variables". If I remove the line where I initialize to an empty string that warning goes away, but then I get the error, "Cannot find nextStageStep" showing up in my return statement.

What is the issue with the original shadowed variable warning, and is there an alternative way to write this, and/or should I simply ignore the tslint warning in this situation?

The linter complains because you are redefining the same variable multiple times. Thus replacing the ones in the closure containing it.

Instead of redeclaring it just use it:

private getNextStageStep(currentDisciplineSelected) {
    let nextStageStep = '';
        if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 1') {
             nextStageStep = 'step 2';
        } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 2') {
             nextStageStep = 'step 3';
        } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 3') {
             nextStageStep = 'step 4';
        } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 4') {
             nextStageStep = 'step 5';
        } else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 5') {
             nextStageStep = 'step 6';
    }
    return nextStageStep;
}

What does 'to make sense of something' mean?, to clarify it in a way that it becomes more understandable or clear. make sense of. make sense (out) of (something) To interpret something in a way that one can understand or that reveals some purpose, reason, etc. It will be a long time before we can begin to make sense of this tragedy.

This has to do with defining the same variable in different scopes. You are defining nextStageStep within the function scope & also within each if block. One option is to get rid of the variable declarations in the if blocks

if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 1') {
   nextStageStep = 'step 2';
} else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 2') {
   nextStageStep = 'step 3';
} else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 3') {
   nextStageStep = 'step 4';
} else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 4') {
   nextStageStep = 'step 5';
} else if (this.stageForDiscipline(this.currentDisciplineSelected) === 'step 5') {
   nextStageStep = 'step 6';
}

Here is a good resource on shadowed variables http://eslint.org/docs/rules/no-shadow

What is another word for "makes sense"?, . To withstand scrutiny or criticism. To seem true, convincing or genuine. Welcome to Making Sense of Cents. Here we talk about personal finance, paying off student loans quickly, how to reach financial independence, money tips, and much more.

You are re-declaring the same variable const nextStageStep in each if block.

Juste replace const nextStageStep = 'step 2'; with nextStageStep = 'step 2'; (and all the other if cases) and it'll be all right.

Is it 'that makes sense' or 'that make sense'? Why?, .” However, if the examples are used as relative clauses inside a sentence then it depends on what the relative pronoun “that” refers to. Making Sense of a Stock Market That Doesn’t Make Any Sense Posted April 25, 2020 by Ben Carlson The past five weeks have seen jobless claims of 3.3 million, 6.9 million, 6.6 million, 5.2 million, and 4.4 million for a grand total of more than 26 million people who filed for unemployment.

Addording to : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const

ES6 const is BLOCK-SCOPED, thus:


{
    const TAG='<yourIt>';
    console.log(TAG);
 }

 {
  const TAG = '<touchingBase NoImNOt="true">';
  console.log(TAG);
 }

 console.log(TAG);  // ERROR expected

AFAICT, this is NOT a case of shadowing - each of the constants is soped correctly within its braces.

If we cannot re-use variable names, we will wind up with unreadable programs that obscure. rather than inform.

I believe the warning is wrong-headed

inexplicable, Define MAKE SENSE OF SOMETHING (phrase) and get synonyms. What is MAKE SENSE OF SOMETHING (phrase)? MAKE SENSE OF SOMETHING (​phrase)  Making Sense of CETA – 2nd edition Published by PowerShift, CCPA et al., Berlin / Ottawa, 2016 This report is available free of charge at https://power-shift.de

In general this error occurs When a variable in a local scope and a variable in the containing scope have the same name, shadowing occurs. Shadowing makes it impossible to access the variable in the containing scope and obscures to what value an identifier actually refers

Refer to this article for code samples explaining this.

MAKE SENSE OF SOMETHING (phrase) definition and synonyms , 1 : to have a clear meaning : to be easy to understand We read the recommendations and thought they made (perfect) sense. The instructions don't make any  The Making Sense of Trauma webinar was developed from a one day workshop that Billy and Kate have been presenting to foster parents, Child & Family Services workers, and other professionals working with children and youth in Manitoba. This webinar succeeds in providing a clear and helpful understanding of trauma and its effects.

Make Sense, Another word for make sense of: understand, appreciate, comprehend, get to the bottom of, get your head round | Collins English Thesaurus. Making Sense Podcast Join Sam Harris—neuroscientist, philosopher, and best-selling author—as he explores some of the most important questions about the human mind, society, and current events. iTunes

Make sense of Synonyms, Find 568 synonyms for "make sense of" and other similar words that you can use instead based on 3 separate contexts from our thesaurus. Making Sense of the Votes in the Ramos v. Louisiana Majority (Updated) Ramos was not nearly as fractured as Apodaca, but the Court is still splintered on the value of precedent

What is another word for "make sense of"?, make (some) sense (out) of someone or something. to understand someone or something. I can't make sense out of Doris and what she has done! No one can  Making Sen$e with Paul Solman is a hub of financial resources featuring economic explainers and more.

Comments
  • well yeah because it's a constant. change it to a let or var
  • This won't work unless nextStageStep is declared as let, instead of const
  • Your example isn't shadowing the constant T, but the original question is with nextStageStep. Shadowing doesn't mean the constant is being redefined illegally (const x = 1; const x = 2), just that there could be an error if you mistake which var/const/let you refer to. It's a matter of opinion whether you allow shadowing, but you can say that this rule picked up the OP's mistake here, so you can see it had some purpose.