RFC: @errorCode to provide context for errors for properties
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- documentation
Research direction
Start by reviewing the existing @link tag behavior and the proposed TypeScript discriminated-union example. Determine how an @errorCode tag should represent property-related diagnostics and what specification changes are needed; done means the syntax and expected error-context behavior are defined clearly enough for implementation.
Written by the indexing model from the issue text.
Description
It would be nice to be able to inform users when they encounter specific errors related to a property.
In this example use case, we would like to inform the user that a property on a discriminated union can only be set when the discriminator matches the type.
interface Base {
discriminator: boolean;
foo: string | never;
}
interface UnionTypeA extends Base {
discriminator: true;
foo: string;
}
interface UnionTypeB extends Base {
discriminator: false;
/**
*
* {@errorCode 2322 | This property can only be set when discriminator is equal to `true`}
*
*/
foo: never;
}
type DiscriminatedUnion = UnionTypeA | UnionTypeB;
const bar: DiscriminatedUnion = {
discriminator: false,
foo: ""
}
The current error is shown as:
I based the syntax around what I have seen as prior art in the @link tag.
Apologies if this has been suggested or discussed before, I could not find anything from an initial search of issues.
- Dominant language
- TypeScript
- Stars
- 5k
- Forks
- 162
- Avg merge
- 17h 24m
- Merged PRs (30d)
- 8
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 microsoft/tsdoc
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·