How to disable the TypeScript Language Service for particular files?

Answered

I use a library that generates a TypeScript file. IntelliJ will show errors on this file if I open it, thus polluting my tree with red underlines. I cannot add @ts-ignores because the library regenerates the file on each run. I tried completely disabling it under Settings→Languages & Frameworks→TypeScript, and the errors go away. So, I think I want to disable the TypeScript Language Service on just that file.

What I have tried:

  • Add the --excludeFiles flag under Options.
  • Add “watchOptions”: { “excludeFiles”: […] } in tsconfig.json.

How can I do this?

0
5 comments

Unfortunately there is no way to do this. Excluding files fromtsconfig.* won't help when using Webstorm due to https://youtrack.jetbrains.com/issue/WEB-43179/Allow-excluding-ts-files-not-included-in-any-tsconfig.json-from-language-service-processing: if the file is not included in any tsconfig.json, the IDE still uses tsserver to check them

0

Elena Pogorelova Thank you for your response. It looks like the issue you linked is under WebStorm. It should probably be more-so about the TypeScript plugin, right? Doesn't look like it has gained much attention.

Could this be accomplished with a plugin that modifies the TypeScript Language Service? Unfortunately, the TypeScript plugin is not open-source, so it would be difficult to integrate.

0

It should probably be more-so about the TypeScript plugin, right?

WebStorm is a host project for the Typescript plugin

Could this be accomplished with a plugin that modifies the TypeScript Language Service?

 

No:(

 

0

Does the JetBrains license permit me to decompile the TypeScript plugin and rewrite it for personal use? Theorhetically, I could give it the same identifier.

0
I'd say - no, it's covered by JetBrains User Agreement that allows users to use and not decompile or reverse engineer
But I'll contact the legal team to be sure
0

Please sign in to leave a comment.