-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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 tsconfig.yaml in addition to tsconfig.json #40027
Comments
Additionally, addressing the question of "What shortcomings exist with current approaches?" I did note that it was possible to add comments to the Also, maintaining a JSON parser which supports comments is work which is probably better avoided (although I recognize that dropping support for comments in |
@RyanCavanaugh is there a standard for "Received Enough Feedback" or is it just basically "Core devs feel that number of positive respondents is sufficient given the (expected) complexity of the change?" I would note that @alexmiddeleer arguably counts as a positive respondent. |
Please implement this. |
There's no concrete standard. The number of positive respondents is one factor, but we're also considering the qualitative aspects of the verbatim comments -- e.g., are people completely blocked, are they inconvenienced, are they feeling a sense of technical friction, are they resorting to difficult workarounds, etc.. |
@RyanCavanaugh checking in. How are core typescript devs currently feeling about the level of feedback so far? |
Yaml for allowing comments would make my life easier, and help my coworkers too. |
Just so you know, you can already write comments in |
@RyanCavanaugh isn't explaining that to people over and over fun? |
It pays the bills 🙃 |
YAML is a better configuration format than JSON for the same reasons JSON is better than XML: by forcing humans to read noisy input, mistakes are more easily made; by forcing humans to decorate content with extra syntax, copy-paste happens more often and mistakes are more easily made. |
YAML syntax is prettier for me. Hope this will be realized. |
By the way, I think it's pretty obvious to anybody who has seriously worked with YAML, but maybe it's useful to state that it's YAML 1.2 that should be supported, not the legacy, ambiguous, error-prone YAML 1.1 spec. |
Is this in development? Because I think it would be a great addition |
FWIW, I use While I like YAML, I also like keeping things simple. If we have to support more formats then anything reading content from tsconfig is going to need another layer of abstraction / more code. It wouldn't be a big deal if YAML parse/stringify functions were built into the standard (ES20xx), but presently they are not, so this would likely mean adding yet another library to |
@jacobq Thanks for the Here's how I used it:
{
"scripts": {
"build-configs": "yaml2json . --pretty --save",
"develop": "npm run build-configs && gatsby develop"
}
}
Now I can edit the Pros
Cons
For me, the cons outweigh the pros. The deal-breaker for me was how my IDE doesn't give me hints in my non- |
Sorry if this comment is veering off-topic, but I appreciated your (@ChrisCrossCrash) thorough note taking for other interested parties so wanted to respond to your question.
These hints (hover, auto-completion, highlighting, and whatnot) are generally made possible via JSON Schema definitions mapped to those files. IIRC, JetBrains IDEs uses the public schemastore.org catalog; see
I would argue that this complexity is the cost of the feature. It can either be put into your projects (annoying/inelegant) or upstream (still inelegant but no longer so annoying due to being practically invisible), but in any case it must exist somewhere. More choices (JSON/YAML/TOML/INI/XML/fill-in-the-blank) + more human-friendliness is nice but not free. Another solution path to consider would be to make an "add-on" module/lib/tool that contains this functionality and can be dropped into your projects -- keeping the functionality isolated without bloating the core upstream package. How that's done depends a lot on your specific project/build arrangement, of course. One way would be to make a If the core team believes that the value of adding a feature like this is worth the cost (effort, maintenance, doc, support, ...) that's all fine and good. In my experience, though, I set up |
This is typically something that should be abstracted for you by an |
fact: most devs have ocd but yeah, I would love to be able to use yaml for tsconfig |
@RyanCavanaugh I would offer my technical reasoning for why allowing the easier to read and write YAML is a logically sound. Firstly, every programming language that I know does not support the commented JSON format. Not even nodeJS, try this:
So does paying someone to compare documents, but I believe there's a great reason Microsoft created the "track changes" feature in Microsoft Word. Secondly, in defense of NPM (and other package managers) using I'm quite sure the community would be happy to help with PR that helps in the effort part, as long as it won't be rejected for reasons other than it doesn't work or breaks something. |
Additionally, putting comments in While Microsoft have already taken the stance in the past that they don't care about this issue, I think it would be better if a The problem this issue addresses is that |
I hope that it is clear that this issue is not only about the comments. There is significant precedence as noted above (eslint and prettier) Furthermorewhich, quite frankly, could be seen as embarrassing that typescript itself doesn't. |
I'll bump this once more, because it would really improve developer experience when we'd be able to write TS config in YAML ❤️
|
I totally agree with this. Except for this one, all of my other settings file are written in yaml. It's more clear and human readable. |
Yes please. Since moving to PNPM, we switched from package.json to package.yaml for improved readability and ergonomics (including, but not limited to comments). Would love to do the same for our tsconfigs. |
Just to add another argument in favor of yaml: The configuration of typescript in combination with the other parts of tooling like babel, metro, vite, webpack etc. is horribly complex and confusing. This is a VERY BIG DOWNSIDE of the freedom of the whole JS centred ecosystem. Every tool evolves independently and the more successful ones become kind of standard (without proper process of standarization). As a developer I have spent countless hours trying to figure out the correct configuration for my toolstack. A very painful process. One reason for this being so difficult is because developers can not put comments in JSON and as such can not embed the contextual information that is actually the reason for a certain config option to be set this way or another. Period! It is freaking annoying and a painful limitation and drawback of JSON format when used for actual coding (not just data). I think that support yaml as format for tsconfig would mean a very big improvement to the future of the TS ecosystem. So, actually...why the resistance to ship this change? |
Would rather see |
I support something like this request, purely on the merits of the following observation for tsconfig:
https://code.visualstudio.com/docs/languages/json#_json-with-comments I have zero qualms with JSON. However, labeling a file as JSON immediately invokes expectations of its content. I have been using tsconfig.json happily for years without issue. Today, this naming misnomer caused a demonstrably competent, smart, senior engineer to make a smart, but incorrect assumption. A formatter update started appending commas to final items in arrays in our tsconfig. "That's not valid JSON" they noticed, which prompted a bunch of activity to protect our automated builds/release pipelines... which was all not necessary, because of course, tsconfig.json is not json. I've observed peer developers on more than one occasion try and read/parse tsconfig.json with JSON.parse, etc unsuccessfully. By marking a non-json file as json, developer friction has observably ensued. It's not a huge deal, but it's completely avoidable for an enormous population of users. Dropping tsconfig.json support is a non-starter (I presume all parties are aligned there). Going forward, however, I advocate the default config file extension should be honest about its format.
|
Many web tools use yml, but this is perhaps not the best format. |
Search Terms
yaml
tsconfig format
Suggestion
I suggest allowing the
tsconfig.json
file to be replaced withtsconfig.yaml
.This would be implemented by simply converting the yaml to json and passing it to whatever method currently interprets the contents of
tsconfig.json
.Additionally, I would propose that the presence of both a
tsconfig.json
and atsconfig.yaml
file in the root of a project is an error.Use Cases
Like #30400 (which I found originally), I'd like to add comments to my project config. Also, yaml is just a nicer format for something intended to be edited by a human.
I have created this simply because #30400 (which called for adding
tsconfig.js
) was closed for reasons which do not apply to yaml. So I thought there should be an open issue. You can always close it for other reasons, right?Examples
following the example in the handbook
Checklist
I'M PRETTY SURE My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: