0

I've seen various answers on how to generally disable TypeScript compilation in Visual Studio. What I have yet to see is how to disable this for specific files. I have a project where some of my coworkers are still using VS's TypeScript, and others are using Webpack. Ideally, eventually we will move completely to one or the other, but for the time being is there an easy way to get VS to not compile specific TypeScript files?

I have already tried setting Build Action to Content. That alone does not seem to be sufficient.

1
  • Post the contents of your msbuild files. Commented Apr 16, 2019 at 14:40

1 Answer 1

2

Something similar to this issue?

If you are using a tsconfig.json file, then the build settings (i.e. which files to exclude from compilation) should be specified in there. It doesn't use the settings on the items in the MSBuild file.

I guess you have a tsconfig.json file in the project.(Not certainly sure,if I misunderstand anything, feel free to contact me). And the setting in that file block the settings in project=>properties like below:

enter image description here

an easy way to get VS to not compile specific TypeScript files?

Set the build action of the tsconfig.json file to None so that it won't block msbuild settings.(Your 'content' build action for xx.ts)

Note: 1. After setting the tsconfig.json file to None,you need to unload and then reload the project to make that change take effect.

Note: 2. Go Tools=>Options=>TextEditor=>JavaScript/TypeScript=>Project make the Automatically compile TypeScript files which are not part of a project disabled.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! Setting the tsconfig.json content type to None did it. I had previously worked around the thing by simply removing it from the project. Here kid, have a reputation cookie. ;-)
Glad to know it helps.
For some reason my project started compilation of TS files outside my project. I had to toggle on and then back off the Automatically compile TypeScript files which are not part of a project in Note 2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.