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

Allow comments in tsconfig.json #210

Closed
RehanSaeed opened this issue Sep 26, 2015 · 11 comments
Closed

Allow comments in tsconfig.json #210

RehanSaeed opened this issue Sep 26, 2015 · 11 comments

Comments

@RehanSaeed
Copy link

Comments don't seem to be allowed in the tsconfig.json file. See this article for why it is ok according to Douglas Crockford to add them to json config files.

This is the error I get when adding comments to my tsconfig.json file:

var typescript = require("gulp-typescript");
var typeScriptProject = ts.createProject("tsconfig.json");
Process terminated with code 0.
> cmd.exe /c gulp -b "C:\Test\WebApplication1\WebApplication1" --color --gulpfile "C:\Test\WebApplication1\WebApplication1\Gulpfile.js" build-js
SyntaxError: Unexpected token /
    at Object.parse (native)
    at Function.createProject (C:\Test\WebApplication1\WebApplication1\node_modules\gulp-typescript\release\main.js:195:40)
    at Object.<anonymous> (C:\Test\WebApplication1\WebApplication1\Gulpfile.js:68:28)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Liftoff.handleArguments (C:\Test\WebApplication1\WebApplication1\node_modules\gulp\bin\gulp.js:116:3)
    at Liftoff.<anonymous> (C:\Test\WebApplication1\WebApplication1\node_modules\gulp\node_modules\liftoff\index.js:192:16)
    at module.exports (C:\Test\WebApplication1\WebApplication1\node_modules\gulp\node_modules\liftoff\node_modules\flagged-respawn\index.js:17:3)
Process terminated with code 8.
    at Liftoff.<anonymous> (C:\Test\WebApplication1\WebApplication1\node_modules\gulp\node_modules\liftoff\index.js:185:9)
    at C:\Test\WebApplication1\WebApplication1\node_modules\gulp\node_modules\liftoff\index.js:159:9
    at C:\Test\WebApplication1\WebApplication1\node_modules\gulp\node_modules\v8flags\index.js:99:14
    at C:\Test\WebApplication1\WebApplication1\node_modules\gulp\node_modules\v8flags\index.js:38:7
    at process._tickCallback (node.js:419:13)
@ivogabe
Copy link
Owner

ivogabe commented Sep 26, 2015

I think this should be implemented in TypeScript first. If this would be implemented in gulp-typescript only, you cannot use the tsconfig file in VSCode for instance, whereas this configuration file was designed to be a universal config file. I'm not sure whether such issue has already been reported at the TypeScript repository. If not, you can report an issue there.

@RehanSaeed
Copy link
Author

@ivogabe Thanks, I've raised a new issue on the official TypeScript project. Let's see what happens.

@jods4
Copy link

jods4 commented Feb 24, 2016

@ivogabe Time to reopen this issue I think!
TS 1.8 now includes support for comments in tsconfig.json.
Unfortunately we can't use them in combination with gulp-typescript because it does its own parsing based on JSON.parse, which does not support comments.

@ivogabe ivogabe reopened this Feb 25, 2016
@aliok
Copy link

aliok commented Feb 25, 2016

👍
I got the same problem. Running tsc works perfect with a commented tsconfig.json but not with gulp-typescript.

FYI, TS people just removed the JSON comments and then parsed the file.

See sarod/TypeScript@b60d88f

@jods4
Copy link

jods4 commented Feb 25, 2016

Most robust approach would be to call parseConfigFileTextToJson() if possible, I see it's exported (from the module it's defined in, at least).
Otherwise probably copy their code?

It's not as intuitive as you'd think, for instance it supports # as line comments.

@aliok
Copy link

aliok commented Feb 26, 2016

Well, that solution I posted is changed a lot by the TS people while merging into TS.

This is their merged solution:
microsoft/TypeScript@3e63144

See the discussion:
microsoft/TypeScript#5450

@ivogabe ivogabe added Bug and removed External labels Feb 26, 2016
@aliok
Copy link

aliok commented Feb 26, 2016

Thanks for fixing the issue. Any plans about release?

@ivogabe
Copy link
Owner

ivogabe commented Feb 26, 2016

Probably next week

@RehanSaeed
Copy link
Author

@ivogabe Has this feature made it out yet?

@ivogabe
Copy link
Owner

ivogabe commented Mar 7, 2016

It has been added in v2.12.1

@aliok
Copy link

aliok commented Mar 7, 2016

@ivogabe Great!
Confirmed, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants