microsoft / microsoft/TypeScript
Support import of jsonc file to infer type
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Suggestion
🔍 Search Terms
typescript
jsonc
json jsonc
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
Enable supporting import of jsonc file to provide typing information.
import * as data from './test.jsonc';
type myType = typeof data;
The import statement for jsonc is not supported today.
📃 Motivating Example
import * as data from './test.jsonc';
type myType = typeof data;
💻 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing TypeScript support for importing JSON and compare it with the requested JSONC import scenario. Define the expected typing and type inference behavior for the example, then identify the tests needed to demonstrate supported JSONC imports; the issue names no files or existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100