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

🐛 Tsconfig.json file always throw errors "expected a property but instead found '}'" #237

Closed
1 task done
harrytran998 opened this issue Sep 11, 2023 · 11 comments
Closed
1 task done

Comments

@harrytran998
Copy link

harrytran998 commented Sep 11, 2023

Environment information

CLI:
  Version:                      1.1.2
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           macos

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v18.17.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "bun/1.0.0"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Note:
Here is the full output I printed to the .txt file(sorry, the file is 25mbs --> I uploaded this file to the Easyupload --> https://easyupload.io/tv6oym

image

What happened?

image

The repo is open-source --> You can pull to the local and check directly https://github.com/techmely/monorepo/blob/main/packages/utils/tsconfig.json

Expected result

Should work correctly 😆. Thank for your work <3 I love this product!

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@nhedger
Copy link
Member

nhedger commented Sep 11, 2023

The JSON specification does not allow trailing commas, try removing it.

{
    "extends": "../configs/tsconfig.base.json",
    "include": ["src", "../../reset.d.ts"],
    "exclude": ["dist", "node_modules"],
    "compilerOptions": {
        "baseUrl": ".",
-       "module": "esnext",
+       "module": "esnext"
    }
}

@ematipico
Copy link
Member

For whoever comes here and sees the issue, the trailing comma is not part of the JSON specifications, but VSCode client allows to do that for a specific number of files.

This is not a biome issue, although we have a proposal to implement this in the parser: #129

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2023
@mirumirumi
Copy link

@ematipico
I think I saw somewhere in the biome documentation something like "some well-known .jsonc files, such as .vscode/settings.json, can suppress extraneous warnings", doesn't tsconfig.json apply? I too have always had trouble with trailing commas in tsconfig.json.
Or if I am doing something wrong, sorry.

@ematipico
Copy link
Member

@mirumirumi

Yes, we do have these kinds of files, although I am not sure where to document them:

pub(crate) const ALLOWED_FILES: &'static [&'static str; 15] = &[
"typescript.json",
"tsconfig.json",
"jsconfig.json",
"tslint.json",
"babel.config.json",
".babelrc.json",
".ember-cli",
"typedoc.json",
".eslintrc.json",
".eslintrc",
".jsfmtrc",
".jshintrc",
".swcrc",
".hintrc",
".babelrc",
];

Yes, tsconfig.json is there, although we ignore it on purpose:

Some("package.json" | "package-lock.json" | "tsconfig.json" | "jsconfig.json")

@mirumirumi
Copy link

@ematipico
Thank you your response.
I understand that this is the intended specification. I would like to continue to use rome/biome for many years to come, so I will write tsconfig.json according to that intention :)
BTW, why is it being excluded once it is listed under ALLOWED_FILES?

@ematipico
Copy link
Member

BTW, why is it being excluded once it is listed under ALLOWED_FILES?

That's a good question, and that's because I had forgotten that it was ignored! 😜🤣😅

I think it makes sense to add this information to the website, not sure where though. Do you have any suggestion?

@mirumirumi
Copy link

mirumirumi commented Oct 20, 2023

@ematipico

That's a good question, and that's because I had forgotten that it was ignored! 😜🤣😅

I'm glad I could be of help in some small way! :)
This means that biome will also suppress warnings in tsconfig.json?

I think it makes sense to add this information to the website, not sure where though. Do you have any suggestion?

As far as I could find, the description of jsonc is here (https://biomejs.dev/blog/biome-v1/#jsonc-support-and-comments). It does not appear to be in the documentation (https://biomejs.dev/*).
Also, if you look closely, you will see that it says "comments can now be written in tsconfig.json" but it does not say "no warning about trailing commas". What is the actual implementation?

If you want to add about these explanations in the documentation, why not create a page under Guides (https://biomejs.dev/guides/*)?
Almost everyone who uses biome should be concerned about its behavior in tsconfig.json, etc.

@ematipico
Copy link
Member

I believe, initially, we ignored tsconfig.json because TS applies particular formatting to the file, and we didn't want to disrupt it. The same is for package.json and package-lock.json.

If you want to add about these explanations in the documentation, why not create a page under Guides (biomejs.dev/guides*)?

Good suggestion, I will do it

@ghiscoding
Copy link
Contributor

I have similar problems with launch.json (VSCode debugger) since the default template created by VSCode is to always add these comments. Can launch.json be added to the list of exception? Or is there a way to extend the list of exceptions? I don't want to use json.parser.allowComments since it's a global action and not recommended but VSCode always create this launch.json with the comments nonetheless so I won't be the only user facing this problem

image

@Conaclos
Copy link
Member

Conaclos commented Feb 6, 2024

@ghiscoding You can use overrides in the configuration.

@ghiscoding
Copy link
Contributor

oh ok that's good to know but that won't that completely ignore the entire file so if I break the JSON format in the future, let say I remove a comma at the end of a property, then I'm guessing that Biome won't detect the broken file.

Anyway, at the end of the day, I just removed the comment on top of the file and Biome was happy, I just thought of mentioning it in here as a use case since many developers will face this one day or another. So an exception for any VSCode files would be better (not just tsconfig.json).

Thanks

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

No branches or pull requests

6 participants