Mapped-type creating redundant intermediary definition (--aliasRefs)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- tooling
Research direction
Start by running the TypeScript example with --aliasRefs and inspect the generated definitions. Trace mapped-type alias handling and compare the MappedType/$ref and __type output; done means the redundant __type intermediary is no longer emitted while the schema remains correct.
Written by the indexing model from the issue text.
Description
Possibly related to #232, although this seems more complicated than that.
Given the following TypeScript:
enum MyEnum { MY, AWESOME, ENUM }
type MappedType = { [key in MyEnum]?: string };
interface Type {
map: MappedType;
}
The following schema is generated (with --aliasRefs):
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"MappedType": {
"$ref": "#/definitions/__type"
},
"__type": {
"properties": {
"0": {
"type": "string"
},
"1": {
"type": "string"
},
"2": {
"type": "string"
}
},
"type": "object"
}
},
"properties": {
"map": {
"$ref": "#/definitions/MappedType"
}
},
"type": "object"
}
As you can see there's a "intermediary" (and very much redundant) definitions created for the mapped type (__type). The actual MappedType definition references this definition.
No seperate enum definition is created, which makes sense because it's never truly referenced. If I do create an explicit reference the enum is generated correctly.
- Dominant language
- TypeScript
- Stars
- 3.3k
- Forks
- 332
- PR merge metrics
- No merged PRs in 30d
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.
More from YousefED/typescript-json-schema
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
YousefED/typescript-json-schema#640 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
YousefED/typescript-json-schema#633 · 6 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
YousefED/typescript-json-schema#626 · 1 comment ·
All issues in YousefED/typescript-json-schema
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·