microsoft / microsoft/TypeScript
Type assertions using Exact, Subset, Superset
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
I have suffered several times with the limitations of casting like so:
res.json(<Foo>{foo:'bar'});
the above cast/assertion will work even if the anonymous object does not have all the fields in type Foo.
For example, this question I had: https://stackoverflow.com/questions/53328459/prevent-compilation-unless-all-fields-exist
This feature request is for something like this:
res.json(Exact<Foo>{foo:'bar'});
res.json(Subset<Foo>{foo:'bar'});
res.json(Superset<Foo>{foo:'bar'});
note this is similar to the existing construct Partial, as in Partial<T>, hopefully the above are self-explanatory. I am not sure if both Subset<> and Superset<> make sense, but one of them should.
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 proposed Exact, Subset, and Superset type-assertion syntax and compare it with the existing Partial construct. Define which semantics are required, including whether both Subset and Superset are needed; the issue names no files, tests, or entry points, so completion would require establishing the design and its validation criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100