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

Forced Strikethrough on word 'name' in simple console.log statement #117401

Closed
RyanFoli opened this issue Feb 23, 2021 · 4 comments
Closed

Forced Strikethrough on word 'name' in simple console.log statement #117401

RyanFoli opened this issue Feb 23, 2021 · 4 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@RyanFoli
Copy link

RyanFoli commented Feb 23, 2021

[<!--](url
IMG_20210211_205133649
Uploading Copy of Copy of IMG_20210211_205036517.jpg…
IMG_20210211_205133649

) ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->

  • VS Code Version:
  • OS Version:

Steps to Reproduce:

Does this issue occur when all extensions are disabled?: Yes/No

BUG: THIS IS NOT THE SAME AS THE OTHER ISSUE. IF IT IS, THERE IS NO SOLUTION STATED

When I type this code into MY vs code:

const name = 'Roger'
console.log(name)

When I type that code into MY vs code, vs code forces the word 'name' in the console.log statement to have a strike through. It only happens with the word 'name'. I can type any other word and no strikethrough.

Now, even though this happens, it still prints the output fine. So the output for the above code in my vs code is:

Roger

So the statement prints to the console fine, but I dont understand why only MY vs code is bahaving this way. I am the only student in the class with this problem and the teacher was unable to reproduce my problem in their mac vs code.

When I put the cursor on the word 'name' with the strikethrough in the console.log statement, intellisense says:

const name: void
@deprecated
'name' is deprecated ts (6385)
no quick fixes available

UPDATE: I have no extensions on my vs code

VS Code version: Code 1.53.2 (622cb03, 2021-02-11T11:48:04.245Z)
OS version: Windows_NT x64 10.0.19042

System InfoExtensions: none
A/B Experiments

@IllusionMH
Copy link
Contributor

/duplicate of #114725
As was mentioned in #117392 - this is already existing issue tracked in TS repo microsoft/TypeScript#18433

This is design limitation of TS - you don't have import/export which means your code is in global scope and overlaps with global name which is marked as deprecated to avoid unintentional use (Make typo variable declaration in const nome ... or if you add several scripts to page and forget to add file that declares name then all code below would use global name instead of your variable).

You should either force module scope or don't use name. And track TS issue for updates and provide feedback there.

@RyanFoli
Copy link
Author

RyanFoli commented Feb 23, 2021

Thanks for the reply!

I was following the code of a teacher in a node.js course. His code had no problem and he never told us to change anything in our vs code after we installed it.

Why didnt the teacher have this problem when typing in THEIR vs code?
How can I force module scope?
So I shouldnt use the term 'name' then? When coding in vs code...ever?

@IllusionMH
Copy link
Contributor

IllusionMH commented Feb 23, 2021

If it's recording or old VS Code version it might not be there yet - this behavior appeared in VS Code only in 1.52 (early December).

If you use modules then import/export statements will force file as module.
But if you don't use modules and write code that won't be run in browser you'll need to create jsconfig.json (see TSConfig Reference and node12 for example) and configure lib to NOT include dom.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

4 participants
@IllusionMH @weinand @RyanFoli and others