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

Support JSON with comments (tsconfig) #11

Open
jonaskello opened this issue Dec 18, 2023 · 3 comments
Open

Support JSON with comments (tsconfig) #11

jonaskello opened this issue Dec 18, 2023 · 3 comments

Comments

@jonaskello
Copy link

The tsconfig.json file supports comments. When I tried to use this package to sync tsconfig.json with package.json I got an error message for existing tsconfig.json files:

❯ p meta-updater
ERROR: Error while processing /xxx/tsconfig.json: Expected property name or '}' in JSON at position 4
ERROR: Error while processing /xxx/tsconfig.json: Expected property name or '}' in JSON

I think this is because those files have comments. Perhaps JSON could be parsed with JSON5 instead to allow for this?

@jonaskello
Copy link
Author

jonaskello commented Dec 18, 2023

I realised that using JSON5 you would still loose the comments when writing the file back. In order to preserve the comments we would probably need to use something like momoa.

https://github.com/hjson allows roundtrip of comments.

@b0o
Copy link

b0o commented Jan 31, 2024

I'm running into this issue. Did you find a solution?

@jonaskello
Copy link
Author

@b0o Unfortunately not yet. We ended up just stripping the comments from all tsconfig.json files.

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

2 participants