YousefED / YousefED/typescript-json-schema
Don't expand defined types
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.3k
- Forks
- 332
- PR merge metrics
- No merged PRs in 30d
Description
This input will produce a schema where the type Result is not used in Response:
export type Result = { key: string };
export type Response = {
items: { [name: string]: Result };
};
This is the output:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Response": {
"properties": {
"items": {
"additionalProperties": {
"properties": {
"key": {
"type": "string"
}
},
"type": "object"
},
"type": "object"
}
},
"type": "object"
},
"Result": {
"properties": {
"key": {
"type": "string"
}
},
"type": "object"
}
}
}
It works with interfaces:
export interface Result { key: string }
export interface Response {
items: { [name: string]: Result };
}
Contributor guide
No contributing guide indexed for this repository
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
Reproduce the issue with the TypeScript definitions shown in the report and inspect the schema-generation path that handles type aliases versus interfaces. Confirm that Response.items references Result in the generated schema rather than expanding it, while preserving the existing definitions output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100