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

Comments

Projects
None yet
@ivogabe
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

This comment has been minimized.

Show comment
Hide comment
@danquirk

danquirk Mar 12, 2015

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?

Member

danquirk commented Mar 12, 2015

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 label Mar 12, 2015

@ivogabe

This comment has been minimized.

Show comment
Hide comment
@ivogabe

ivogabe Mar 12, 2015

Contributor

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

Contributor

ivogabe commented Mar 12, 2015

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

@mhegazy

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy Mar 12, 2015

Contributor

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 :)

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

This comment has been minimized.

Show comment
Hide comment
@ivogabe

ivogabe Mar 12, 2015

Contributor

@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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@ivogabe
Contributor

ivogabe commented Mar 16, 2015

@johnnyreilly

This comment has been minimized.

Show comment
Hide comment
@johnnyreilly

johnnyreilly Mar 16, 2015

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?

johnnyreilly commented Mar 16, 2015

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

This comment has been minimized.

Show comment
Hide comment
@ivogabe

ivogabe Mar 16, 2015

Contributor

@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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@danquirk

danquirk Mar 16, 2015

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.

Member

danquirk commented Mar 16, 2015

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

This comment has been minimized.

Show comment
Hide comment
@basarat

basarat Mar 16, 2015

Contributor

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 ❤️

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 basarat referenced this issue Mar 16, 2015

Closed

Move compileOnSave into tsconfig.json #187

3 of 3 tasks complete
@ivogabe

This comment has been minimized.

Show comment
Hide comment
@ivogabe

ivogabe Mar 17, 2015

Contributor

@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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@basarat

basarat Mar 17, 2015

Contributor

@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.

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

This comment has been minimized.

Show comment
Hide comment
@basarat

basarat Mar 17, 2015

Contributor

@ivogabe perhaps compileOnBuild for visual studio ?

Contributor

basarat commented Mar 17, 2015

@ivogabe perhaps compileOnBuild for visual studio ?

@ivogabe

This comment has been minimized.

Show comment
Hide comment
@ivogabe

ivogabe Mar 17, 2015

Contributor

@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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@basarat

basarat Mar 17, 2015

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@nycdotnet

nycdotnet Mar 25, 2015

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.

nycdotnet commented Mar 25, 2015

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

This comment has been minimized.

Show comment
Hide comment
@basarat

basarat May 4, 2015

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@basarat

basarat May 4, 2015

Contributor

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.

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 and removed Suggestion labels May 4, 2015

@mhegazy

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy May 4, 2015

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@paulvanbrenk

paulvanbrenk May 21, 2015

Contributor

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

Contributor

paulvanbrenk commented May 21, 2015

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

@gyzerok

This comment has been minimized.

Show comment
Hide comment
@gyzerok

gyzerok Sep 15, 2015

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

gyzerok commented Sep 15, 2015

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

@nycdotnet

This comment has been minimized.

Show comment
Hide comment
@nycdotnet

nycdotnet Sep 15, 2015

@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

nycdotnet commented Sep 15, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@gyzerok

gyzerok commented Sep 15, 2015

@nycdotnet thanks bro!

@mhegazy

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy Oct 26, 2015

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@paulvanbrenk

paulvanbrenk Oct 26, 2015

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

Contributor

paulvanbrenk commented Oct 26, 2015

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

This comment has been minimized.

Show comment
Hide comment
@thomas-darling

thomas-darling Dec 9, 2015

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 :-)

thomas-darling commented Dec 9, 2015

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

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy Jan 15, 2016

Contributor

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

Contributor

mhegazy commented Jan 15, 2016

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

@johnnyreilly

This comment has been minimized.

Show comment
Hide comment
@johnnyreilly

johnnyreilly commented Jan 15, 2016

Yay!

@paulvanbrenk

This comment has been minimized.

Show comment
Hide comment
@paulvanbrenk

paulvanbrenk Feb 2, 2016

Contributor

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

Contributor

paulvanbrenk commented Feb 2, 2016

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

@johnnyreilly

This comment has been minimized.

Show comment
Hide comment
@johnnyreilly

johnnyreilly Feb 2, 2016

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

johnnyreilly commented Feb 2, 2016

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

@netdragonboberb

This comment has been minimized.

Show comment
Hide comment
@netdragonboberb

netdragonboberb Nov 11, 2016

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

netdragonboberb commented Nov 11, 2016

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

@ofirgeller

This comment has been minimized.

Show comment
Hide comment
@ofirgeller

ofirgeller Jan 8, 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.

ofirgeller commented Jan 8, 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.

@mhegazy

This comment has been minimized.

Show comment
Hide comment
@mhegazy

mhegazy Jan 9, 2017

Contributor

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.

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.