microsoft / microsoft/typespec

Introduce mapped types expressions as in typescript

Open
#9,035 0 comments 0 reactions 0 assignees View on GitHub
compiler:core design:needed triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

### Clear and concise description of the problem

Instead of writing decorators for omiting or requiring fields, there should be easier and more native construct in the language to achieve this.
E.g. I want to make all fields Nullable, or conditionally Nullable, or construct variations of models based on subset of fields in my model, so I'm forced to write custom decorator for that, instead of just expressing this in the language.
This would also simplify lot's of specific types utils development and introspection. Some very limited and primitive subset of what TypeScript can do atm with mapped types would suffice, like simple mapping, adding/removing optionality. This makes models parsing also easier in a sense that it eliminates additional decorators from an AST and forces work with more native language constructs.

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Read the [docs](https://typespec.io/docs/).
- [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.