Open gkhub opened 1 year ago
Unfortunately -- and ironically -- import { compilerOptions } from 'tsconfig.json';
doesn't usually work. It would be great to be able to import jsonc
files as easily as importing regular json
files.
Importing json files with comments should be supported. Comments are much needed in the configuration files which are mostly json. I know that the json spec prohibits comments, but everyone is eventually pushed to support comments, which would mean that the spec should change too. Even tsconfig.json supports comments, but like @gerardo-lima-moonfare mentioned, you cannot import it :)
I might be wrong here, but I seem to remember that the JSON spec allows a parser to accept comments, but not to emit them when serializing. So it would likely be compliant to just allow importing them directly too.
Is there any update on this 👀 ?
+1 for this, would be really useful
Suggestion
🔍 Search Terms
typescript jsonc
json jsonc
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
Enable supporting import of jsonc file to provide typing information.
The import statement for jsonc is not supported today.
📃 Motivating Example
💻 Use Cases
Our scenario auto generates UX based on declarative jsonc file. We have a requirement to load and infer the type specified in the jsonc file to invoke some component in the UX. There is no typing support currently and workaround is to manually construct the data.