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

Please, separate Typescript from Javascript, so I can disable TS and keep JS! #239670

Closed
blaasvaer opened this issue Feb 5, 2025 · 13 comments
Closed
Assignees
Labels
*as-designed Described behavior is as designed javascript JavaScript support issues

Comments

@blaasvaer
Copy link

I need a setting where I can disable TS ONLY and not only TS AND Javascript at the same time.

Separate them!

@gjsjohnmurray
Copy link
Contributor

Why? What problems are you having?

@blaasvaer
Copy link
Author

blaasvaer commented Feb 5, 2025 via email

@albertosantini
Copy link

Use jsconfig and not tsconfig.

https://code.visualstudio.com/docs/languages/jsconfig

@blaasvaer
Copy link
Author

blaasvaer commented Feb 5, 2025 via email

@albertosantini
Copy link

About hiding node_modules is not the default because there is not consensus about this settings: people think different. :)

Generally speaking, in javascript (or typescript) project I add the following settings in .vscode folder of the project root:

{
    "files.exclude": {
        "**/node_modules": true
    },
    "search.exclude": {
        "**/node_modules": true
    }
}

Sometimes, when I work on a sort of low-level debugging in the deps, I remove those settings, because it is useful to have node_modules in the explorer and in the searches.

Your mileage may vary.

Hope that helps.

@preston206
Copy link

preston206 commented Feb 6, 2025

I just came here to post the same thing. I've been putting it off for a while because I was hoping that VSC would fix it. With each update I hope for improvement on this topic, but no. We shouldn't need to create a separate file to exclude unrelated errors and warnings. TS is nowhere in any of my projects, but I still have to use // @ts-ignore littered all throughout my files. It's annoying and causing a poor user experience.

I also want to be able to disable these warnings without removing other useful features.

@albertosantini
Copy link

I cannot reproduce it.

My setup is using a jsconfig file (doc link above for details) in the root of the project like

{
    "compilerOptions": {
        "checkJs": true,
        "module": "ESNext",
        "moduleResolution": "Node",
        "target": "ES2020"
    },
    "exclude": [
        "node_modules",
        "**/node_modules/*"
    ]
}

I have not relevant settings enabled.

If you use ts features in a js file, I think that kind of error is expected.

@blaasvaer
Copy link
Author

blaasvaer commented Feb 6, 2025

Well, that's my point: I DON'T use ANY TS features in my project – I have NO files with the suffix of .ts. But STILL TypeScript is messing with me.

Simply: SPLIT the settings for TS and JS in the settings, so we can relate to them as two SEPARATE things. They are NOT the same.

If VSC finds NO files with the suffix of .ts anywhere in my project (ignoring node_modules, as I have no control of what's in there .ts wise), it should leave me and my project alone and not annoy me with "trying to help (convert my JS code to TS)".

@albertosantini
Copy link

If I am not wrong, when the file is a js or, generally speaking, it is a javascript project, you don'want any lint line in Problems panel marked ts(NNNN) [Ln X Col Y]?

@albertosantini
Copy link

If the answer is yes to my previous question, this is the setting you need to disable ts validation for js files:

"javascript.validate.enable": false

@blaasvaer
Copy link
Author

blaasvaer commented Feb 6, 2025

It seems absolutely counter intuitive to specifically DISABLE javascript validation ("javascript.validate.enable": false), when you want to disable TS validation!?

I WANT JS validation
I DO NOT WANT TS validation

The crazy thing is that VSC 'think' I want TS validation even though NONE of my files have .ts file suffix.

What am I NOT getting about this?

@albertosantini
Copy link

That setting will disable only the validation with typescript compiler.
Tha would no be a TS validation, it is a validation of javascript code with a typescript tool.

If you set, for instance, eslint linter, it will work as expected, even if there is that setting in place.

Recap. Just to see if I answered to your question. :)

  • you don't need to change the extension of your files. Use js extension.
  • with last setting suggested, you disabled the validation of js files with typescript tool.
  • as opt-in, you can use eslint linter and it will work as expected in despite of that setting

Hope that helps.

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 7, 2025

What am I NOT getting about this?

The features you see in JS files are designed specifically for JavaScript. They all happen to be powered by TypeScript behind the scenes, but this is not TypeScript somehow being forced onto you. We also provide settings to disable any of these features if you find them getting in the way

Let's consider error reporting since this is probably the easies to misunderstand. Again we will only show errors that we think make sense for JavaScript (which out of the box is pretty much just syntax errors). Now if you do look at a error, you do see ts, even in js files:

Image

But that ts(8010) is just an error code. You probably don't care about it at all but these error codes can be useful for searching web to learn more about the error. It's ts because typescript is ultimately who generates the error, but again it's validating your javascript as javascript. If you are seeing this error it's because we think it makes sense to show in JS files

It's the same for all the other features you mention, such as IntelliSense and suggested code actions. These are all designed specifically for JavaScript, they just happened to be implemented by TypeScript behind the scenes

@mjbvz mjbvz closed this as completed Feb 7, 2025
@mjbvz mjbvz added javascript JavaScript support issues *as-designed Described behavior is as designed labels Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*as-designed Described behavior is as designed javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

5 participants