RFC: @errorCode to provide context for errors for properties
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5k
- Forks
- 162
- Avg merge
- 17h 24m
- Merged PRs (30d)
- 8
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.
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
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.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100