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

Add no-compile option to tsconfig #2326

Closed
ivogabe opened this issue Mar 12, 2015 · 34 comments
Closed

Add no-compile option to tsconfig #2326

ivogabe opened this issue Mar 12, 2015 · 34 comments
Assignees
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript Visual Studio Integration with Visual Studio

Comments

@ivogabe
Copy link
Contributor

ivogabe commented Mar 12, 2015

Some users want to use the built-in compilation of their IDE, but some want to use grunt or gulp. If you want to use grunt or gulp for compilation, you need to disable compilation in your IDE. Since a big team can use multiple IDEs, I think this should be implemented in tsconfig.json.

Suggestion: Add a new option to tsconfig.json to disable the compilation in the IDE ("compile on save"), which defaults to false.

Example:

{
    "disableCompileOnSave": true,
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true
    },
    "files": [
        "foo.ts",
        "bar.ts"
    ]
}

If an IDE finds a config file with this option, it shouldn't compile the project, but it should give auto completions, type errors, etcetera. If a build tool sees this option it should ignore it, because you use an IDE always for writing, sometimes for building and you use a build system always for building.

@danquirk
Copy link
Member

You mean full build not compile on save right? Compile on save is already toggleable in VS and using (or not using) --watch on the command line. It sounds like you want something similar to this #2294 but provided in tsconfig?

@danquirk danquirk added the Suggestion An idea for TypeScript label Mar 12, 2015
@ivogabe
Copy link
Contributor Author

ivogabe commented Mar 12, 2015

Yes, that's what I meant. It should be something like disableIdeCompilation or disableCompilation then.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 12, 2015

Your IDE build is triggered by the msbuild targets in your project file. if you want to stop that, open your project file, and comment out the reference to Microsoft.TypeScript.Targets, and no build will occur. no need for a different file here :)

@ivogabe
Copy link
Contributor Author

ivogabe commented Mar 12, 2015

@mhegazy Unless someone else in your team uses another editor, like Atom. You can disable it in Atom, but defining it once in tsconfig would be better.

@ivogabe
Copy link
Contributor Author

ivogabe commented Mar 16, 2015

@johnnyreilly
Copy link

As I understand it this switch would support those users who are using Gulp or Grunt to do their TypeScript compilation and they don't want Visual Studio / atom-typescript / sublime etc to get involved in doing a build.

As @mhegazy says we can already cater for this in Visual Studio by tweaking the project file.

As regards atom-typescript etc I understand there's a an agreement that we can extend the tsconfig.json file already (as long as we don't conflict with existing settings.

That being the case I'm not sure this needs an official tsconfig.json flag (although I guess it'd be nicer?) Is it enough if we just extend it unofficially?

@basarat - do you have a view on this?

@ivogabe
Copy link
Contributor Author

ivogabe commented Mar 16, 2015

@johnnyreilly That's a good summary. There is a big advantage for this to be official, since if it's official, all editors should support it. That makes it easier for these users: they can configure this option once and it will be disabled in all editors. That's very useful if you have a big team or an open source project.

@danquirk
Copy link
Member

I'm inclined to agree. If enough people want this in enough different scenarios then there's value in just standardizing the name of the flag rather than having some people use noCompile and someone else use skipCompile and someone else use yet another option.

@basarat
Copy link
Contributor

basarat commented Mar 16, 2015

I recommend compileOnSave (default true). Atom-typescript already supports this as a package option, that you can even configure per project : https://github.com/TypeStrong/atom-typescript/blob/master/docs/packages.md#manage-your-projects

👍 on moving this into tsconfig.json. I'll do that.

PS: Having a negative like disable in a variable name is a bad idea. Double negation is not easy for the human brain. "disableCompileOnSave": false,. I've done this myself too and sometimes it does make sense, so no judgement ❤️

@basarat
Copy link
Contributor

basarat commented Mar 17, 2015

@ivogabe
Copy link
Contributor Author

ivogabe commented Mar 17, 2015

@basarat I chose for disable since it can then default to false, and undefined is false-ish. But I can also life without disable. As pointed out by @danquirk compileOnSave might not be the right name for it, since that would mean that Visual Studio should only disable automatic compilation, not the compile button. I'd call it something like ideCompilation, or maybe better: externalCompilation, which defaults to false and doesn't have a double negotiation. externalCompilation: true would mean you're using Gulp, Grunt, Jake etcetera.

@basarat
Copy link
Contributor

basarat commented Mar 17, 2015

@danquirk compileOnSave might not be the right name for it, since that would mean that Visual Studio should only disable automatic compilation, not the compile button

I specifically want to disable "compile" OnSave. For Atom-TypeScript build is an explicit option triggered by the user. If they don't trigger it, it doesn't happen. Compile on save is what happened as a side effect of saving and so it needed configuration.

I guess you want to disable all IDE compile. That seems like a Visual Studio / exclude from MSBuild problem, not related to other other IDEs. At the very least don't see it as an option we need to read in Atom-TypeScript.

@basarat
Copy link
Contributor

basarat commented Mar 17, 2015

@ivogabe perhaps compileOnBuild for visual studio ?

@ivogabe
Copy link
Contributor Author

ivogabe commented Mar 17, 2015

@basarat Do you mean adding two different options to tsconfig.json? I think it would be better to make these two one, especially because many (all?) users want to enable them both, or disable them both. I think disabling a build option hidden in a submenu isn't a problem, since setting this option means you shouldn't compile TypeScript from an editor since a build system should do that.

@basarat
Copy link
Contributor

basarat commented Mar 17, 2015

I think it would be better to make these two one, especially because many (all?) users want to enable them both

I agree. ideBuild? : disables compile on save and compile on build.

@nycdotnet
Copy link

I think ideBuild, editorBuild, or even vsBuild are fine option names with the default being true for IDEs or Visual Studio in particular. I wrote up "some" (probably too many) thoughts on this here #2294 (comment) , but the bottom line is that the ability to disable Visual Studio's TypeScript build functionality while retaining the ability to use the TypeScript build properties UI would be really useful.

@basarat
Copy link
Contributor

basarat commented May 4, 2015

I previously went with compileOnSave at root. https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#compileonsave

After discussion with @Zoltu here TypeStrong/atom-typescript#324 I'll be moving to :

"ide": {
    "compileOnSave" : boolean
}

Please leave a comment if you disagree. Note that in my opinion build and onsave are different events.

@basarat
Copy link
Contributor

basarat commented May 4, 2015

After letting it sit in my brain I dislike my proposal. Perhaps for the user the option is important for gulp to read. Really it belongs in something like "atom" key and then the user should lookup what options are supported by their ide / build tool.

At the moment I'll leave the options I have as they are. If I do something wonky (tsconfig for me has been fairly stable) I'll do it under atom from this point on.

@mhegazy mhegazy added Discussion Issues which may not have code impact and removed Suggestion An idea for TypeScript labels May 4, 2015
@mhegazy
Copy link
Contributor

mhegazy commented May 4, 2015

Does not seem that there is an action item here per se. switching it to discussion from suggestion.

@paulvanbrenk
Copy link
Contributor

For VS 2015 we have included the TypeScriptCompileBlocked msbuild element, this will block tsc from being invoked during a build.

@gyzerok
Copy link

gyzerok commented Sep 15, 2015

Any progress on this? I'm using Atom and bundle my code with webpack.

@nycdotnet
Copy link

@gyzerok Atom-typescript has an unofficial extension to tsconfig.json for this: compileOnSave.

https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#compileonsave

@gyzerok
Copy link

gyzerok commented Sep 15, 2015

@nycdotnet thanks bro!

@mhegazy
Copy link
Contributor

mhegazy commented Oct 26, 2015

compileOnSave seems like a fine property name to standardize on. we are currently looking into #5287, and we will need a way to make this honored in VS. so +1 for compileOnSave.

@paulvanbrenk
Copy link
Contributor

Sounds like something that would be more appropriate in something like .editorconfig? tsconfig.json is primarily designed to drive the compiler and compilation context... just my $0.02

@thomas-darling
Copy link

Just a quick comment on this - it looks like much of the conversation here is centered around enabling/disabling compile-on-save for all typescript in a project - i.e. on the use case where only one tsconfig.json exists in the project. However, that's not the only use case for this:

In my case, I have more than one tsconfig.json within a single Visual Studio project, with one specifying compile options for the app code, and another for compiling some custom tslint rules.
To avoid an overly complicated build setup, I would strongly prefer to only use gulp to compile my app code, while just relying on compile-on-save for other things, such as custom tslint rules or gulp tasks.

I just wanted to point out this use case, so it doesn't get lost in the conversation :-)

@mhegazy
Copy link
Contributor

mhegazy commented Jan 15, 2016

After discussing this with @paulvanbrenk, VS should honor the compileOnSave property in tsconfig if present.

@mhegazy mhegazy added Suggestion An idea for TypeScript Visual Studio Integration with Visual Studio and removed Discussion Issues which may not have code impact labels Jan 15, 2016
@mhegazy mhegazy added this to the TypeScript 1.8 milestone Jan 15, 2016
@johnnyreilly
Copy link

Yay!

@paulvanbrenk
Copy link
Contributor

compileOnSave should be in for 1.8 final, I checked it in.

@paulvanbrenk paulvanbrenk added the Fixed A PR has been merged for this issue label Feb 2, 2016
@johnnyreilly
Copy link

I've been experiencing difficulties with it... See #6782

@netdragonboberb
Copy link

netdragonboberb commented Nov 11, 2016

.njsproj files also work for TypeScriptCompileBlocked. See also https://shauntm.com/notes/entries/231

@ofirgeller
Copy link

How about compile on save for just some files? my files should not be compiled on save as I use gulp to do that. but I actually write my gulpfile as a typescript file and I need that file to compile on save.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 9, 2017

How about compile on save for just some files? my files should not be compiled on save as I use gulp to do that. but I actually write my gulpfile as a typescript file and I need that file to compile on save.

have to tsconfig.json files, one at the root for your gulpFile, and one in a source directory for your sources. the top one allows compile on save, the other one does not.

regardless, i do not think you can rely on compile on save for your gulp file, as you want it to run on a CI server for instance that does not have an editor. consider using something like ts-node instead.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript Visual Studio Integration with Visual Studio
Projects
None yet
Development

No branches or pull requests